#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*/ fflush(int /*<<< orphan*/);
int /*<<< orphan*/ printf(char *, ...);
int /*<<< orphan*/ scanf(char *, int *);
int /*<<< orphan*/ sleep(int);
int /*<<< orphan*/ stdout;
int main() {
  int sec_count;
  int sec_down;
  int min_count;
  int min_down;
  int dummy = 0;
  printf("\nMinutes: ");
  scanf("%i", &min_count);
  printf("Seconds: ");
  scanf("%i", &sec_count);
  printf("\n");
  while (dummy == 0) {
    if (min_count > 0) {
      printf("%i minutes and %i seconds remaining", min_count, sec_count);
      fflush(stdout);
    }
    if (min_count == 0) {
      printf("%i seconds remaining", sec_count);
      fflush(stdout);
    }
    if (min_count == 0 && sec_count == 0) {
      printf("\r                                            \r");
      printf("Ding! Timer's done.\a\n\n");
      return 0;
    }
    switch (sec_down) {
    default:
      sec_down = sec_count - 1;
    }
    switch (sec_count) {
    default:
      sec_count = sec_down;
    }
    if (sec_count == -1) {
      switch (min_down) {
      default:
        min_down = min_count - 1;
      }
      switch (min_count) {
      default:
        min_count = min_down;
      }
    }
    if (sec_count == -1) {
      switch (sec_count) {
      default:
        sec_count = 59;
      }
    }
    sleep(1);
    printf("\r                                            \r");
  }
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
movl   $0x0,-0x4(%rbp)
movl   $0x0,-0x18(%rbp)
lea    0xea3(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
lea    0xea0(%rip),%rdi
lea    -0x10(%rbp),%rsi
call   1050 <scanf@plt>
lea    0xe93(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
lea    0xe82(%rip),%rdi
lea    -0x8(%rbp),%rsi
call   1050 <scanf@plt>
lea    0xee7(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
cmpl   $0x0,-0x18(%rbp)
jne    129b <main+0x15b>
cmpl   $0x0,-0x10(%rbp)
jle    11d6 <main+0x96>
mov    -0x10(%rbp),%esi
mov    -0x8(%rbp),%edx
lea    0xe57(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
mov    0x2e11(%rip),%rax
mov    (%rax),%edi
call   1040 <fflush@plt>
cmpl   $0x0,-0x10(%rbp)
jne    11ff <main+0xbf>
mov    -0x8(%rbp),%esi
lea    0xe3d(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
mov    0x2de8(%rip),%rax
mov    (%rax),%edi
call   1040 <fflush@plt>
cmpl   $0x0,-0x10(%rbp)
jne    123b <main+0xfb>
cmpl   $0x0,-0x8(%rbp)
jne    123b <main+0xfb>
lea    0xe22(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
lea    0xe43(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
movl   $0x0,-0x4(%rbp)
jmp    129b <main+0x15b>
mov    -0x8(%rbp),%eax
sub    $0x1,%eax
mov    %eax,-0xc(%rbp)
mov    -0xc(%rbp),%eax
mov    %eax,-0x8(%rbp)
cmpl   $0xffffffff,-0x8(%rbp)
jne    1268 <main+0x128>
mov    -0x10(%rbp),%eax
sub    $0x1,%eax
mov    %eax,-0x14(%rbp)
mov    -0x14(%rbp),%eax
mov    %eax,-0x10(%rbp)
jmp    1268 <main+0x128>
cmpl   $0xffffffff,-0x8(%rbp)
jne    127e <main+0x13e>
movl   $0x3b,-0x8(%rbp)
jmp    127e <main+0x13e>
mov    $0x1,%edi
call   1060 <sleep@plt>
lea    0xdad(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
jmp    11a0 <main+0x60>
mov    -0x4(%rbp),%eax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %r15
push   %r14
push   %r12
push   %rbx
push   %rax
lea    0xe91(%rip),%rdi
xor    %eax,%eax
call   1050 <printf@plt>
lea    0xe8e(%rip),%rbx
lea    0x4(%rsp),%rsi
mov    %rbx,%rdi
call   1070 <scanf@plt>
lea    0xe7d(%rip),%rdi
xor    %eax,%eax
call   1050 <printf@plt>
mov    %rsp,%rsi
mov    %rbx,%rdi
call   1070 <scanf@plt>
mov    $0xa,%edi
call   1030 <putchar@plt>
lea    0xe64(%rip),%r15
mov    0x2e25(%rip),%r12
lea    0xe65(%rip),%r14
lea    0xe73(%rip),%rbx
jmp    11e4 <main+0x84>
nopl   0x0(%rax,%rax,1)
mov    $0x1,%edi
call   1080 <sleep@plt>
mov    %rbx,%rdi
xor    %eax,%eax
call   1050 <printf@plt>
mov    0x4(%rsp),%esi
test   %esi,%esi
jle    1206 <main+0xa6>
mov    (%rsp),%edx
mov    %r15,%rdi
xor    %eax,%eax
call   1050 <printf@plt>
mov    (%r12),%edi
call   1060 <fflush@plt>
mov    0x4(%rsp),%esi
mov    (%rsp),%eax
test   %esi,%esi
jne    122f <main+0xcf>
mov    %r14,%rdi
mov    %eax,%esi
xor    %eax,%eax
call   1050 <printf@plt>
mov    (%r12),%edi
call   1060 <fflush@plt>
mov    0x4(%rsp),%esi
mov    (%rsp),%eax
mov    %esi,%ecx
or     %eax,%ecx
je     1247 <main+0xe7>
sub    $0x1,%eax
mov    %eax,(%rsp)
jae    11d0 <main+0x70>
add    $0xffffffff,%esi
mov    %esi,0x4(%rsp)
movl   $0x3b,(%rsp)
jmp    11d0 <main+0x70>
lea    0xdee(%rip),%rdi
xor    %eax,%eax
call   1050 <printf@plt>
lea    0xe0f(%rip),%rdi
call   1040 <puts@plt>
xor    %eax,%eax
add    $0x8,%rsp
pop    %rbx
pop    %r12
pop    %r14
pop    %r15
ret

LLVM IR (-O0):
@.str = [11 x i8] c"\0AMinutes: \00"
@.str.1 = [3 x i8] c"%i\00"
@.str.2 = [10 x i8] c"Seconds: \00"
@.str.3 = [2 x i8] c"\0A\00"
@.str.4 = [36 x i8] c"%i minutes and %i seconds remaining\00"
@stdout = global i32 0
@.str.5 = [21 x i8] c"%i seconds remaining\00"
@.str.6 = [47 x i8] c"\0D \0D\00"
@.str.7 = [23 x i8] c"Ding! Timer's done.\07\0A\0A\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* %6
%7 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([11 x i8], [11 x i8]* @.str, i64 0, i64 0))
%8 = call i32 @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0), i32* %4)
%9 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([10 x i8], [10 x i8]* @.str.2, i64 0, i64 0))
%10 = call i32 @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0), i32* %2)
%11 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.3, i64 0, i64 0))
br label %12
12: ; preds = %70, %0
%13 = load i32, i32* %6
%14 = icmp eq i32 %13, 0
br i1 %14, label %15, label %73
15: ; preds = %12
%16 = load i32, i32* %4
%17 = icmp sgt i32 %16, 0
br i1 %17, label %18, label %24
18: ; preds = %15
%19 = load i32, i32* %4
%20 = load i32, i32* %2
%21 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([36 x i8], [36 x i8]* @.str.4, i64 0, i64 0), i32 %19, i32 %20)
%22 = load i32, i32* @stdout
%23 = call i32 @fflush(i32 %22)
br label %24
24: ; preds = %18, %15
%25 = load i32, i32* %4
%26 = icmp eq i32 %25, 0
br i1 %26, label %27, label %32
27: ; preds = %24
%28 = load i32, i32* %2
%29 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([21 x i8], [21 x i8]* @.str.5, i64 0, i64 0), i32 %28)
%30 = load i32, i32* @stdout
%31 = call i32 @fflush(i32 %30)
br label %32
32: ; preds = %27, %24
%33 = load i32, i32* %4
%34 = icmp eq i32 %33, 0
br i1 %34, label %35, label %41
35: ; preds = %32
%36 = load i32, i32* %2
%37 = icmp eq i32 %36, 0
br i1 %37, label %38, label %41
38: ; preds = %35
%39 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([47 x i8], [47 x i8]* @.str.6, i64 0, i64 0))
%40 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([23 x i8], [23 x i8]* @.str.7, i64 0, i64 0))
store i32 0, i32* %1
br label %73
41: ; preds = %35, %32
%42 = load i32, i32* %3
switch i32 %42, label %43 [
]
43: ; preds = %41
%44 = load i32, i32* %2
%45 = sub nsw i32 %44, 1
store i32 %45, i32* %3
br label %46
46: ; preds = %43
%47 = load i32, i32* %2
switch i32 %47, label %48 [
]
48: ; preds = %46
%49 = load i32, i32* %3
store i32 %49, i32* %2
br label %50
50: ; preds = %48
%51 = load i32, i32* %2
%52 = icmp eq i32 %51, -1
br i1 %52, label %53, label %63
53: ; preds = %50
%54 = load i32, i32* %5
switch i32 %54, label %55 [
]
55: ; preds = %53
%56 = load i32, i32* %4
%57 = sub nsw i32 %56, 1
store i32 %57, i32* %5
br label %58
58: ; preds = %55
%59 = load i32, i32* %4
switch i32 %59, label %60 [
]
60: ; preds = %58
%61 = load i32, i32* %5
store i32 %61, i32* %4
br label %62
62: ; preds = %60
br label %63
63: ; preds = %62, %50
%64 = load i32, i32* %2
%65 = icmp eq i32 %64, -1
br i1 %65, label %66, label %70
66: ; preds = %63
%67 = load i32, i32* %2
switch i32 %67, label %68 [
]
68: ; preds = %66
store i32 59, i32* %2
br label %69
69: ; preds = %68
br label %70
70: ; preds = %69, %63
%71 = call i32 @sleep(i32 1)
%72 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([47 x i8], [47 x i8]* @.str.6, i64 0, i64 0))
br label %12
73: ; preds = %38, %12
%74 = load i32, i32* %1
ret i32 %74
}

LLVM IR (-O2):
@.str = [11 x i8] c"\0AMinutes: \00"
@.str.1 = [3 x i8] c"%i\00"
@.str.2 = [10 x i8] c"Seconds: \00"
@.str.4 = [36 x i8] c"%i minutes and %i seconds remaining\00"
@stdout = global i32 0
@.str.5 = [21 x i8] c"%i seconds remaining\00"
@.str.6 = [47 x i8] c"\0D \0D\00"
@str = [22 x i8] c"Ding! Timer's done.\07\0A\00"
define i32 @main() {
%1 = alloca i32
%2 = alloca i32
%3 = bitcast i32* %1 to i8*
%4 = bitcast i32* %2 to i8*
%5 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([11 x i8], [11 x i8]* @.str, i64 0, i64 0))
%6 = call i32 @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0), i32* %2)
%7 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([10 x i8], [10 x i8]* @.str.2, i64 0, i64 0))
%8 = call i32 @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0), i32* %1)
%9 = call i32 @putchar(i32 10)
br label %10
10: ; preds = %43, %0
%11 = load i32, i32* %2
%12 = icmp sgt i32 %11, 0
br i1 %12, label %13, label %19
13: ; preds = %10
%14 = load i32, i32* %1
%15 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([36 x i8], [36 x i8]* @.str.4, i64 0, i64 0), i32 %11, i32 %14)
%16 = load i32, i32* @stdout
%17 = call i32 @fflush(i32 %16)
%18 = load i32, i32* %2
br label %19
19: ; preds = %13, %10
%20 = phi i32 [ %18, %13 ], [ %11, %10 ]
%21 = icmp eq i32 %20, 0
%22 = load i32, i32* %1
br i1 %21, label %26, label %23
23: ; preds = %19
%24 = icmp eq i32 %22, 0
%25 = add nsw i32 %22, -1
store i32 %25, i32* %1
br i1 %24, label %40, label %43
26: ; preds = %19
%27 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([21 x i8], [21 x i8]* @.str.5, i64 0, i64 0), i32 %22)
%28 = load i32, i32* @stdout
%29 = call i32 @fflush(i32 %28)
%30 = load i32, i32* %2
%31 = icmp eq i32 %30, 0
%32 = load i32, i32* %1
%33 = icmp eq i32 %32, 0
%34 = select i1 %31, i1 %33, i1 false
br i1 %34, label %35, label %38
35: ; preds = %26
%36 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([47 x i8], [47 x i8]* @.str.6, i64 0, i64 0))
%37 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([22 x i8], [22 x i8]* @str, i64 0, i64 0))
ret i32 0
38: ; preds = %26
%39 = add nsw i32 %32, -1
store i32 %39, i32* %1
br i1 %33, label %40, label %43
40: ; preds = %23, %38
%41 = phi i32 [ %20, %23 ], [ %30, %38 ]
%42 = add nsw i32 %41, -1
store i32 %42, i32* %2
store i32 59, i32* %1
br label %43
43: ; preds = %23, %38, %40
%44 = call i32 @sleep(i32 1)
%45 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([47 x i8], [47 x i8]* @.str.6, i64 0, i64 0))
br label %10
}