#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 */
typedef int /*<<< orphan*/ time_t;

/* Variables and functions */
char *ctime(int /*<<< orphan*/ *);
int /*<<< orphan*/ printf(char *);
int /*<<< orphan*/ sleep(int);
int strcmp(char *, char *);
int /*<<< orphan*/ time(int /*<<< orphan*/ *);
int main(int argc, char *argv[]) {
  printf("This program will run indefinitely \n");
  printf("Or just 50 iterations if you add the -h flag \n");
  char *flag = "-h";
  if (argc == 2) {
    if (strcmp(argv[0], flag) == 1 || strcmp(argv[1], flag) == 1) {
      printf("-h Supplied. Will only loop 50 times. \n");
      printf("Weenie. \n");
      for (int i = 0; i < 50; i++) {
        time_t current;
        current = time(NULL);
        printf(ctime(&current));
        sleep(30);
      }
    } else {
      while (1 == 1) {
        time_t current;
        current = time(NULL);
        printf(ctime(&current));
        sleep(30);
      }
    }
  } else {
    while (1 == 1) {
      time_t current;
      current = time(NULL);
      printf(ctime(&current));
      sleep(30);
    }
  }
  return 1;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
movl   $0x0,-0x4(%rbp)
mov    %edi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
lea    0xe93(%rip),%rdi
call   1040 <printf@plt>
lea    0xeac(%rip),%rdi
call   1040 <printf@plt>
lea    0xecf(%rip),%rax
mov    %rax,-0x18(%rbp)
cmpl   $0x2,-0x8(%rbp)
jne    125f <main+0x10f>
mov    -0x10(%rbp),%rax
mov    (%rax),%rdi
mov    -0x18(%rbp),%rsi
call   1050 <strcmp@plt>
cmp    $0x1,%eax
je     11c6 <main+0x76>
mov    -0x10(%rbp),%rax
mov    0x8(%rax),%rdi
mov    -0x18(%rbp),%rsi
call   1050 <strcmp@plt>
cmp    $0x1,%eax
jne    1229 <main+0xd9>
lea    0xe8a(%rip),%rdi
call   1040 <printf@plt>
lea    0xea6(%rip),%rdi
call   1040 <printf@plt>
movl   $0x0,-0x1c(%rbp)
cmpl   $0x32,-0x1c(%rbp)
jge    1224 <main+0xd4>
xor    %eax,%eax
mov    %eax,%edi
call   1060 <time@plt>
mov    %eax,-0x20(%rbp)
lea    -0x20(%rbp),%rdi
call   1030 <ctime@plt>
mov    %rax,%rdi
call   1040 <printf@plt>
mov    $0x1e,%edi
call   1070 <sleep@plt>
mov    -0x1c(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x1c(%rbp)
jmp    11e5 <main+0x95>
jmp    125a <main+0x10a>
jmp    122e <main+0xde>
xor    %eax,%eax
mov    %eax,%edi
call   1060 <time@plt>
mov    %eax,-0x24(%rbp)
lea    -0x24(%rbp),%rdi
call   1030 <ctime@plt>
mov    %rax,%rdi
call   1040 <printf@plt>
mov    $0x1e,%edi
call   1070 <sleep@plt>
jmp    122e <main+0xde>
jmp    1290 <main+0x140>
jmp    1264 <main+0x114>
xor    %eax,%eax
mov    %eax,%edi
call   1060 <time@plt>
mov    %eax,-0x28(%rbp)
lea    -0x28(%rbp),%rdi
call   1030 <ctime@plt>
mov    %rax,%rdi
call   1040 <printf@plt>
mov    $0x1e,%edi
call   1070 <sleep@plt>
jmp    1264 <main+0x114>
mov    $0x1,%eax
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbp
push   %rbx
sub    $0x18,%rsp
mov    %rsi,%rbx
mov    %edi,%ebp
lea    0xe91(%rip),%rdi
call   1030 <puts@plt>
lea    0xea9(%rip),%rdi
call   1030 <puts@plt>
cmp    $0x2,%ebp
jne    11e7 <main+0x87>
mov    (%rbx),%rdi
lea    0xe6e(%rip),%rsi
call   1060 <strcmp@plt>
cmp    $0x1,%eax
je     1217 <main+0xb7>
mov    0x8(%rbx),%rdi
lea    0xe59(%rip),%rsi
call   1060 <strcmp@plt>
cmp    $0x1,%eax
je     1217 <main+0xb7>
lea    0x10(%rsp),%rbx
cs nopw 0x0(%rax,%rax,1)
xor    %edi,%edi
call   1070 <time@plt>
mov    %eax,0x10(%rsp)
mov    %rbx,%rdi
call   1040 <ctime@plt>
mov    %rax,%rdi
call   1050 <printf@plt>
mov    $0x1e,%edi
call   1080 <sleep@plt>
jmp    11c0 <main+0x60>
lea    0xc(%rsp),%rbx
nopl   0x0(%rax)
xor    %edi,%edi
call   1070 <time@plt>
mov    %eax,0xc(%rsp)
mov    %rbx,%rdi
call   1040 <ctime@plt>
mov    %rax,%rdi
call   1050 <printf@plt>
mov    $0x1e,%edi
call   1080 <sleep@plt>
jmp    11f0 <main+0x90>
lea    0xe37(%rip),%rdi
call   1030 <puts@plt>
lea    0xe52(%rip),%rdi
call   1030 <puts@plt>
mov    $0x32,%ebp
lea    0x14(%rsp),%rbx
nopl   0x0(%rax)
xor    %edi,%edi
call   1070 <time@plt>
mov    %eax,0x14(%rsp)
mov    %rbx,%rdi
call   1040 <ctime@plt>
mov    %rax,%rdi
call   1050 <printf@plt>
mov    $0x1e,%edi
call   1080 <sleep@plt>
add    $0xffffffff,%ebp
jne    1240 <main+0xe0>
mov    $0x1,%eax
add    $0x18,%rsp
pop    %rbx
pop    %rbp
ret

LLVM IR (-O0):
@.str = [37 x i8] c"This program will run indefinitely \0A\00"
@.str.1 = [47 x i8] c"Or just 50 iterations if you add the -h flag \0A\00"
@.str.2 = [3 x i8] c"-h\00"
@.str.3 = [40 x i8] c"-h Supplied. Will only loop 50 times. \0A\00"
@.str.4 = [10 x i8] c"Weenie. \0A\00"
define i32 @main(i32 %0, i8** %1) {
%3 = alloca i32
%4 = alloca i32
%5 = alloca i8**
%6 = alloca i8*
%7 = alloca i32
%8 = alloca i32
%9 = alloca i32
%10 = alloca i32
store i32 0, i32* %3
store i32 %0, i32* %4
store i8** %1, i8*** %5
%11 = call i32 @printf(i8* getelementptr inbounds ([37 x i8], [37 x i8]* @.str, i64 0, i64 0))
%12 = call i32 @printf(i8* getelementptr inbounds ([47 x i8], [47 x i8]* @.str.1, i64 0, i64 0))
store i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.2, i64 0, i64 0), i8** %6
%13 = load i32, i32* %4
%14 = icmp eq i32 %13, 2
br i1 %14, label %15, label %51
15: ; preds = %2
%16 = load i8**, i8*** %5
%17 = getelementptr inbounds i8*, i8** %16, i64 0
%18 = load i8*, i8** %17
%19 = load i8*, i8** %6
%20 = call i32 @strcmp(i8* %18, i8* %19)
%21 = icmp eq i32 %20, 1
br i1 %21, label %29, label %22
22: ; preds = %15
%23 = load i8**, i8*** %5
%24 = getelementptr inbounds i8*, i8** %23, i64 1
%25 = load i8*, i8** %24
%26 = load i8*, i8** %6
%27 = call i32 @strcmp(i8* %25, i8* %26)
%28 = icmp eq i32 %27, 1
br i1 %28, label %29, label %44
29: ; preds = %22, %15
%30 = call i32 @printf(i8* getelementptr inbounds ([40 x i8], [40 x i8]* @.str.3, i64 0, i64 0))
%31 = call i32 @printf(i8* getelementptr inbounds ([10 x i8], [10 x i8]* @.str.4, i64 0, i64 0))
store i32 0, i32* %7
br label %32
32: ; preds = %40, %29
%33 = load i32, i32* %7
%34 = icmp slt i32 %33, 50
br i1 %34, label %35, label %43
35: ; preds = %32
%36 = call i32 @time(i32* null)
store i32 %36, i32* %8
%37 = call i8* @ctime(i32* %8)
%38 = call i32 @printf(i8* %37)
%39 = call i32 @sleep(i32 30)
br label %40
40: ; preds = %35
%41 = load i32, i32* %7
%42 = add nsw i32 %41, 1
store i32 %42, i32* %7
br label %32
43: ; preds = %32
br label %50
44: ; preds = %22
br label %45
45: ; preds = %44, %45
%46 = call i32 @time(i32* null)
store i32 %46, i32* %9
%47 = call i8* @ctime(i32* %9)
%48 = call i32 @printf(i8* %47)
%49 = call i32 @sleep(i32 30)
br label %45
50: ; preds = %43
br label %57
51: ; preds = %2
br label %52
52: ; preds = %51, %52
%53 = call i32 @time(i32* null)
store i32 %53, i32* %10
%54 = call i8* @ctime(i32* %10)
%55 = call i32 @printf(i8* %54)
%56 = call i32 @sleep(i32 30)
br label %52
57: ; preds = %50
ret i32 1
}

LLVM IR (-O2):
@.str.2 = [3 x i8] c"-h\00"
@str = [36 x i8] c"This program will run indefinitely \00"
@str.5 = [46 x i8] c"Or just 50 iterations if you add the -h flag \00"
@str.6 = [39 x i8] c"-h Supplied. Will only loop 50 times. \00"
@str.7 = [9 x i8] c"Weenie. \00"
define i32 @main(i32 %0, i8** nocapture %1) {
%3 = alloca i32
%4 = alloca i32
%5 = alloca i32
%6 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([36 x i8], [36 x i8]* @str, i64 0, i64 0))
%7 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([46 x i8], [46 x i8]* @str.5, i64 0, i64 0))
%8 = icmp eq i32 %0, 2
br i1 %8, label %11, label %9
9: ; preds = %2
%10 = bitcast i32* %5 to i8*
br label %40
11: ; preds = %2
%12 = load i8*, i8** %1
%13 = tail call i32 @strcmp(i8* dereferenceable(1) %12, i8* dereferenceable(3) getelementptr inbounds ([3 x i8], [3 x i8]* @.str.2, i64 0, i64 0))
%14 = icmp eq i32 %13, 1
br i1 %14, label %22, label %15
15: ; preds = %11
%16 = getelementptr inbounds i8*, i8** %1, i64 1
%17 = load i8*, i8** %16
%18 = tail call i32 @strcmp(i8* dereferenceable(1) %17, i8* dereferenceable(3) getelementptr inbounds ([3 x i8], [3 x i8]* @.str.2, i64 0, i64 0))
%19 = icmp eq i32 %18, 1
br i1 %19, label %22, label %20
20: ; preds = %15
%21 = bitcast i32* %4 to i8*
br label %35
22: ; preds = %15, %11
%23 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([39 x i8], [39 x i8]* @str.6, i64 0, i64 0))
%24 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([9 x i8], [9 x i8]* @str.7, i64 0, i64 0))
%25 = bitcast i32* %3 to i8*
br label %27
26: ; preds = %27
ret i32 1
27: ; preds = %22, %27
%28 = phi i32 [ 0, %22 ], [ %33, %27 ]
%29 = call i32 @time(i32* null)
store i32 %29, i32* %3
%30 = call i8* @ctime(i32* %3)
%31 = call i32 @printf(i8* dereferenceable(1) %30)
%32 = call i32 @sleep(i32 30)
%33 = add nuw nsw i32 %28, 1
%34 = icmp eq i32 %33, 50
br i1 %34, label %26, label %27
35: ; preds = %20, %35
%36 = call i32 @time(i32* null)
store i32 %36, i32* %4
%37 = call i8* @ctime(i32* %4)
%38 = call i32 @printf(i8* dereferenceable(1) %37)
%39 = call i32 @sleep(i32 30)
br label %35
40: ; preds = %9, %40
%41 = call i32 @time(i32* null)
store i32 %41, i32* %5
%42 = call i8* @ctime(i32* %5)
%43 = call i32 @printf(i8* dereferenceable(1) %42)
%44 = call i32 @sleep(i32 30)
br label %40
}