#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 */
int /*<<< orphan*/ printf(char *, ...);
int /*<<< orphan*/ scanf(char *, int *, int *);
int main() {
  int min = 0, sec = 0, num = 0, len = 0;
  int done = 0;
  do {
    printf("Length of song (min:sec) : ");
    scanf("%d:%d", &min, &sec);
    if (min < 0)
      done = !done;
    else if (sec < 0 || sec > 59)
      printf("Invalid entry\n");
    else {
      len += min * 60 + sec;
      num++;
    }
  } while (!done);
  printf("The total play length of %d songs is(hh:mm:ss) %d:%d:%d.", num,
         len / 3600, (len - 3600 * (len / 3600)) / 60,
         len - 3600 * (len / 3600) - 60 * ((len - 3600 * (len / 3600)) / 60));
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
movl   $0x0,-0x4(%rbp)
movl   $0x0,-0x8(%rbp)
movl   $0x0,-0xc(%rbp)
movl   $0x0,-0x10(%rbp)
movl   $0x0,-0x14(%rbp)
movl   $0x0,-0x18(%rbp)
lea    0xea7(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
lea    0xeb5(%rip),%rdi
lea    -0x8(%rbp),%rsi
lea    -0xc(%rbp),%rdx
call   1040 <scanf@plt>
cmpl   $0x0,-0x8(%rbp)
jge    1194 <main+0x74>
cmpl   $0x0,-0x18(%rbp)
setne  %al
xor    $0xff,%al
and    $0x1,%al
movzbl %al,%eax
mov    %eax,-0x18(%rbp)
jmp    11d6 <main+0xb6>
cmpl   $0x0,-0xc(%rbp)
jl     11a8 <main+0x88>
cmpl   $0x3b,-0xc(%rbp)
jle    11bb <main+0x9b>
lea    0xe73(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
jmp    11d1 <main+0xb1>
imul   $0x3c,-0x8(%rbp),%eax
add    -0xc(%rbp),%eax
add    -0x14(%rbp),%eax
mov    %eax,-0x14(%rbp)
mov    -0x10(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x10(%rbp)
jmp    11d6 <main+0xb6>
jmp    11db <main+0xbb>
cmpl   $0x0,-0x18(%rbp)
setne  %al
xor    $0xff,%al
test   $0x1,%al
jne    1152 <main+0x32>
mov    -0x10(%rbp),%esi
mov    -0x14(%rbp),%eax
mov    $0xe10,%ecx
cltd
idiv   %ecx
mov    %eax,-0x1c(%rbp)
mov    -0x14(%rbp),%eax
mov    %eax,-0x24(%rbp)
mov    -0x14(%rbp),%eax
mov    $0xe10,%ecx
cltd
idiv   %ecx
mov    %eax,%ecx
mov    -0x24(%rbp),%eax
imul   $0xe10,%ecx,%ecx
sub    %ecx,%eax
mov    $0x3c,%ecx
cltd
idiv   %ecx
mov    %eax,%ecx
mov    -0x14(%rbp),%r8d
mov    -0x14(%rbp),%eax
mov    $0xe10,%edi
cltd
idiv   %edi
imul   $0xe10,%eax,%eax
sub    %eax,%r8d
mov    -0x14(%rbp),%eax
mov    %eax,-0x20(%rbp)
mov    -0x14(%rbp),%eax
mov    $0xe10,%edi
cltd
idiv   %edi
mov    %eax,%edx
mov    -0x20(%rbp),%eax
imul   $0xe10,%edx,%edx
sub    %edx,%eax
mov    $0x3c,%edi
cltd
idiv   %edi
mov    -0x1c(%rbp),%edx
imul   $0x3c,%eax,%eax
sub    %eax,%r8d
lea    0xdbe(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
xor    %eax,%eax
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
push   %rax
movl   $0x0,(%rsp)
movl   $0x0,0x4(%rsp)
lea    0xeaf(%rip),%rdi
xor    %ebx,%ebx
xor    %eax,%eax
call   1040 <printf@plt>
lea    0xebb(%rip),%rdi
mov    %rsp,%rsi
lea    0x4(%rsp),%rdx
call   1050 <scanf@plt>
mov    (%rsp),%eax
mov    $0x0,%r14d
test   %eax,%eax
js     11e4 <main+0xb4>
lea    0xe7e(%rip),%r15
lea    0xe93(%rip),%r12
mov    %rsp,%r13
lea    0x4(%rsp),%rbp
xor    %r14d,%r14d
xor    %ebx,%ebx
jmp    11cd <main+0x9d>
nopl   0x0(%rax,%rax,1)
imul   $0x3c,%eax,%eax
add    %r14d,%eax
add    %ecx,%eax
add    $0x1,%ebx
mov    %eax,%r14d
mov    %r15,%rdi
xor    %eax,%eax
call   1040 <printf@plt>
mov    %r12,%rdi
mov    %r13,%rsi
mov    %rbp,%rdx
call   1050 <scanf@plt>
mov    (%rsp),%eax
test   %eax,%eax
js     11e4 <main+0xb4>
mov    0x4(%rsp),%ecx
cmp    $0x3c,%ecx
jb     11a0 <main+0x70>
lea    0xe7e(%rip),%rdi
call   1030 <puts@plt>
jmp    11ae <main+0x7e>
movslq %r14d,%rax
imul   $0xffffffff91a2b3c5,%rax,%rdx
shr    $0x20,%rdx
add    %eax,%edx
mov    %edx,%ecx
shr    $0x1f,%ecx
sar    $0xb,%edx
add    %ecx,%edx
imul   $0xfffff1f0,%edx,%ecx
add    %eax,%ecx
movslq %ecx,%rax
imul   $0xffffffff88888889,%rax,%rcx
shr    $0x20,%rcx
add    %eax,%ecx
mov    %ecx,%esi
shr    $0x1f,%esi
sar    $0x5,%ecx
add    %esi,%ecx
imul   $0xffffffc4,%ecx,%r8d
add    %eax,%r8d
lea    0xdf4(%rip),%rdi
mov    %ebx,%esi
xor    %eax,%eax
call   1040 <printf@plt>
xor    %eax,%eax
add    $0x8,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
@.str = [28 x i8] c"Length of song (min:sec) : \00"
@.str.1 = [6 x i8] c"%d:%d\00"
@.str.2 = [15 x i8] c"Invalid entry\0A\00"
@.str.3 = [57 x i8] c"The total play length of %d songs is(hh:mm:ss) %d:%d:%d.\00"
define i32 @main() {
%1 = alloca i32
%2 = alloca i32
%3 = alloca i32
%4 = alloca i32
%5 = alloca i32
%6 = alloca i32
store i32 0, i32* %1
store i32 0, i32* %2
store i32 0, i32* %3
store i32 0, i32* %4
store i32 0, i32* %5
store i32 0, i32* %6
br label %7
7: ; preds = %36, %0
%8 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([28 x i8], [28 x i8]* @.str, i64 0, i64 0))
%9 = call i32 @scanf(i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.1, i64 0, i64 0), i32* %2, i32* %3)
%10 = load i32, i32* %2
%11 = icmp slt i32 %10, 0
br i1 %11, label %12, label %17
12: ; preds = %7
%13 = load i32, i32* %6
%14 = icmp ne i32 %13, 0
%15 = xor i1 %14, true
%16 = zext i1 %15 to i32
store i32 %16, i32* %6
br label %35
17: ; preds = %7
%18 = load i32, i32* %3
%19 = icmp slt i32 %18, 0
br i1 %19, label %23, label %20
20: ; preds = %17
%21 = load i32, i32* %3
%22 = icmp sgt i32 %21, 59
br i1 %22, label %23, label %25
23: ; preds = %20, %17
%24 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([15 x i8], [15 x i8]* @.str.2, i64 0, i64 0))
br label %34
25: ; preds = %20
%26 = load i32, i32* %2
%27 = mul nsw i32 %26, 60
%28 = load i32, i32* %3
%29 = add nsw i32 %27, %28
%30 = load i32, i32* %5
%31 = add nsw i32 %30, %29
store i32 %31, i32* %5
%32 = load i32, i32* %4
%33 = add nsw i32 %32, 1
store i32 %33, i32* %4
br label %34
34: ; preds = %25, %23
br label %35
35: ; preds = %34, %12
br label %36
36: ; preds = %35
%37 = load i32, i32* %6
%38 = icmp ne i32 %37, 0
%39 = xor i1 %38, true
br i1 %39, label %7, label %40
40: ; preds = %36
%41 = load i32, i32* %4
%42 = load i32, i32* %5
%43 = sdiv i32 %42, 3600
%44 = load i32, i32* %5
%45 = load i32, i32* %5
%46 = sdiv i32 %45, 3600
%47 = mul nsw i32 3600, %46
%48 = sub nsw i32 %44, %47
%49 = sdiv i32 %48, 60
%50 = load i32, i32* %5
%51 = load i32, i32* %5
%52 = sdiv i32 %51, 3600
%53 = mul nsw i32 3600, %52
%54 = sub nsw i32 %50, %53
%55 = load i32, i32* %5
%56 = load i32, i32* %5
%57 = sdiv i32 %56, 3600
%58 = mul nsw i32 3600, %57
%59 = sub nsw i32 %55, %58
%60 = sdiv i32 %59, 60
%61 = mul nsw i32 60, %60
%62 = sub nsw i32 %54, %61
%63 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([57 x i8], [57 x i8]* @.str.3, i64 0, i64 0), i32 %41, i32 %43, i32 %49, i32 %62)
ret i32 0
}

LLVM IR (-O2):
@.str = [28 x i8] c"Length of song (min:sec) : \00"
@.str.1 = [6 x i8] c"%d:%d\00"
@.str.3 = [57 x i8] c"The total play length of %d songs is(hh:mm:ss) %d:%d:%d.\00"
@str = [14 x i8] c"Invalid entry\00"
define i32 @main() {
%1 = alloca i32
%2 = alloca i32
%3 = bitcast i32* %1 to i8*
store i32 0, i32* %1
%4 = bitcast i32* %2 to i8*
store i32 0, i32* %2
%5 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([28 x i8], [28 x i8]* @.str, i64 0, i64 0))
%6 = call i32 @scanf(i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.1, i64 0, i64 0), i32* %1, i32* %2)
%7 = load i32, i32* %1
%8 = icmp slt i32 %7, 0
br i1 %8, label %29, label %9
9: ; preds = %0, %22
%10 = phi i32 [ %27, %22 ], [ %7, %0 ]
%11 = phi i32 [ %24, %22 ], [ 0, %0 ]
%12 = phi i32 [ %23, %22 ], [ 0, %0 ]
%13 = load i32, i32* %2
%14 = icmp ugt i32 %13, 59
br i1 %14, label %15, label %17
15: ; preds = %9
%16 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([14 x i8], [14 x i8]* @str, i64 0, i64 0))
br label %22
17: ; preds = %9
%18 = mul nsw i32 %10, 60
%19 = add i32 %18, %11
%20 = add i32 %19, %13
%21 = add nsw i32 %12, 1
br label %22
22: ; preds = %17, %15
%23 = phi i32 [ %12, %15 ], [ %21, %17 ]
%24 = phi i32 [ %11, %15 ], [ %20, %17 ]
%25 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([28 x i8], [28 x i8]* @.str, i64 0, i64 0))
%26 = call i32 @scanf(i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.1, i64 0, i64 0), i32* %1, i32* %2)
%27 = load i32, i32* %1
%28 = icmp slt i32 %27, 0
br i1 %28, label %29, label %9
29: ; preds = %22, %0
%30 = phi i32 [ 0, %0 ], [ %23, %22 ]
%31 = phi i32 [ 0, %0 ], [ %24, %22 ]
%32 = sdiv i32 %31, 3600
%33 = mul nsw i32 %32, -3600
%34 = add i32 %33, %31
%35 = sdiv i32 %34, 60
%36 = mul nsw i32 %35, -60
%37 = add i32 %36, %34
%38 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([57 x i8], [57 x i8]* @.str.3, i64 0, i64 0), i32 %30, i32 %32, i32 %35, i32 %37)
ret i32 0
}