#define NULL ((void *)0)
typedef unsigned long size_t; // Customize by platform.
typedef long intptr_t;
typedef unsigned long uintptr_t;
typedef long scalar_t__; // Either arithmetic or pointer type.
/* By default, we understand bool (as a convenience). */
typedef int bool;
#define false 0
#define true 1

/* Forward declarations */

/* Type definitions */

/* Variables and functions */
double atof(char *);
int atoi(char *);
int detect_colon(char *);
int /*<<< orphan*/ printf(char *, int);
int /*<<< orphan*/ puts(char *);
char *strtok(char *, char *);
int main(int argc, char *argv[]) {
  if (argc < 2) {
    puts("Argument required.");
    return -1;
  }
  int colon_present = detect_colon(argv[1]), mins;
  double total_seconds = 0, secs;
  char *minutes, *seconds;
  if (colon_present) {
    minutes = strtok(*(argv + 1), ":");
    seconds = strtok(NULL, "\0");
    mins = atoi(minutes);
    secs = atof(seconds);
    printf("%g\n", mins * 60 + secs);
  }
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x40,%rsp
movl   $0x0,-0x4(%rbp)
mov    %edi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
cmpl   $0x2,-0x8(%rbp)
jge    1198 <main+0x38>
lea    0xe79(%rip),%rdi
call   1030 <puts@plt>
movl   $0xffffffff,-0x4(%rbp)
jmp    1224 <main+0xc4>
mov    -0x10(%rbp),%rax
mov    0x8(%rax),%rdi
call   1060 <detect_colon@plt>
mov    %eax,-0x14(%rbp)
xorps  %xmm0,%xmm0
movsd  %xmm0,-0x20(%rbp)
cmpl   $0x0,-0x14(%rbp)
je     121d <main+0xbd>
mov    -0x10(%rbp),%rax
mov    0x8(%rax),%rdi
lea    0xe4a(%rip),%rsi
call   1070 <strtok@plt>
mov    %rax,-0x30(%rbp)
xor    %eax,%eax
mov    %eax,%edi
lea    0xe3c(%rip),%rsi
call   1070 <strtok@plt>
mov    %rax,-0x38(%rbp)
mov    -0x30(%rbp),%rdi
call   1080 <atoi@plt>
mov    %eax,-0x18(%rbp)
mov    -0x38(%rbp),%rdi
call   1040 <atof@plt>
movsd  %xmm0,-0x28(%rbp)
imul   $0x3c,-0x18(%rbp),%eax
cvtsi2sd %eax,%xmm0
addsd  -0x28(%rbp),%xmm0
cvttsd2si %xmm0,%esi
lea    0xdfd(%rip),%rdi
call   1050 <printf@plt>
movl   $0x0,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x40,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbp
push   %r15
push   %r14
push   %rbx
push   %rax
cmp    $0x1,%edi
jg     117f <main+0x1f>
lea    0xe8d(%rip),%rdi
call   1030 <puts@plt>
mov    $0xffffffff,%ebx
jmp    11e6 <main+0x86>
mov    %rsi,%rbx
mov    0x8(%rsi),%rdi
call   1060 <detect_colon@plt>
test   %eax,%eax
je     11e4 <main+0x84>
mov    0x8(%rbx),%rdi
lea    0xe79(%rip),%rsi
call   1070 <strtok@plt>
mov    %rax,%r14
lea    0xe70(%rip),%rsi
xor    %ebx,%ebx
xor    %edi,%edi
call   1070 <strtok@plt>
mov    %rax,%r15
mov    %r14,%rdi
call   1080 <atoi@plt>
mov    %eax,%ebp
mov    %r15,%rdi
call   1040 <atof@plt>
imul   $0x3c,%ebp,%eax
cvtsi2sd %eax,%xmm1
addsd  %xmm0,%xmm1
cvttsd2si %xmm1,%esi
lea    0xe38(%rip),%rdi
call   1050 <printf@plt>
jmp    11e6 <main+0x86>
xor    %ebx,%ebx
mov    %ebx,%eax
add    $0x8,%rsp
pop    %rbx
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
@.str = [19 x i8] c"Argument required.\00"
@.str.1 = [2 x i8] c":\00"
@.str.2 = [2 x i8] zeroinitializer
@.str.3 = [4 x i8] c"%g\0A\00"
define i32 @main(i32 %0, i8** %1) {
%3 = alloca i32
%4 = alloca i32
%5 = alloca i8**
%6 = alloca i32
%7 = alloca i32
%8 = alloca double
%9 = alloca double
%10 = alloca i8*
%11 = alloca i8*
store i32 0, i32* %3
store i32 %0, i32* %4
store i8** %1, i8*** %5
%12 = load i32, i32* %4
%13 = icmp slt i32 %12, 2
br i1 %13, label %14, label %16
14: ; preds = %2
%15 = call i32 @puts(i8* getelementptr inbounds ([19 x i8], [19 x i8]* @.str, i64 0, i64 0))
store i32 -1, i32* %3
br label %41
16: ; preds = %2
%17 = load i8**, i8*** %5
%18 = getelementptr inbounds i8*, i8** %17, i64 1
%19 = load i8*, i8** %18
%20 = call i32 @detect_colon(i8* %19)
store i32 %20, i32* %6
store double 0.000000e+00, double* %8
%21 = load i32, i32* %6
%22 = icmp ne i32 %21, 0
br i1 %22, label %23, label %40
23: ; preds = %16
%24 = load i8**, i8*** %5
%25 = getelementptr inbounds i8*, i8** %24, i64 1
%26 = load i8*, i8** %25
%27 = call i8* @strtok(i8* %26, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.1, i64 0, i64 0))
store i8* %27, i8** %10
%28 = call i8* @strtok(i8* null, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.2, i64 0, i64 0))
store i8* %28, i8** %11
%29 = load i8*, i8** %10
%30 = call i32 @atoi(i8* %29)
store i32 %30, i32* %7
%31 = load i8*, i8** %11
%32 = call double @atof(i8* %31)
store double %32, double* %9
%33 = load i32, i32* %7
%34 = mul nsw i32 %33, 60
%35 = sitofp i32 %34 to double
%36 = load double, double* %9
%37 = fadd double %35, %36
%38 = fptosi double %37 to i32
%39 = call i32 @printf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.3, i64 0, i64 0), i32 %38)
br label %40
40: ; preds = %23, %16
store i32 0, i32* %3
br label %41
41: ; preds = %40, %14
%42 = load i32, i32* %3
ret i32 %42
}

LLVM IR (-O2):
@.str = [19 x i8] c"Argument required.\00"
@.str.1 = [2 x i8] c":\00"
@.str.2 = [2 x i8] zeroinitializer
@.str.3 = [4 x i8] c"%g\0A\00"
define i32 @main(i32 %0, i8** nocapture %1) {
%3 = icmp slt i32 %0, 2
br i1 %3, label %4, label %6
4: ; preds = %2
%5 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([19 x i8], [19 x i8]* @.str, i64 0, i64 0))
br label %22
6: ; preds = %2
%7 = getelementptr inbounds i8*, i8** %1, i64 1
%8 = load i8*, i8** %7
%9 = tail call i32 @detect_colon(i8* %8)
%10 = icmp eq i32 %9, 0
br i1 %10, label %22, label %11
11: ; preds = %6
%12 = load i8*, i8** %7
%13 = tail call i8* @strtok(i8* %12, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.1, i64 0, i64 0))
%14 = tail call i8* @strtok(i8* null, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.2, i64 0, i64 0))
%15 = tail call i32 @atoi(i8* %13)
%16 = tail call double @atof(i8* %14)
%17 = mul nsw i32 %15, 60
%18 = sitofp i32 %17 to double
%19 = fadd double %16, %18
%20 = fptosi double %19 to i32
%21 = tail call i32 @printf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.3, i64 0, i64 0), i32 %20)
br label %22
22: ; preds = %6, %11, %4
%23 = phi i32 [ -1, %4 ], [ 0, %11 ], [ 0, %6 ]
ret i32 %23
}