#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 */
scalar_t__ calloc(int, int);
int /*<<< orphan*/ free(char *);
int /*<<< orphan*/ printf(char *, int);
int /*<<< orphan*/ usleep(int);
int main(void) {
  int i = 0;
  char *test = NULL;
  test = (char *)calloc(1 * 1024 * 1024 * 1024, sizeof(char));
  for (i = 0; i < 10; i++) {
    usleep(1000000);
    printf("%02d seconds remaining\n", 10 - i - 1);
  }
  if (test) {
    free(test);
  }
  return (0);
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
movl   $0x0,-0x4(%rbp)
movl   $0x0,-0x8(%rbp)
movq   $0x0,-0x10(%rbp)
mov    $0x40000000,%edi
mov    $0x1,%esi
call   1050 <calloc@plt>
mov    %rax,-0x10(%rbp)
movl   $0x0,-0x8(%rbp)
cmpl   $0xa,-0x8(%rbp)
jge    11b1 <main+0x71>
mov    $0xf4240,%edi
call   1060 <usleep@plt>
mov    $0xa,%esi
sub    -0x8(%rbp),%esi
sub    $0x1,%esi
lea    0xe62(%rip),%rdi
call   1040 <printf@plt>
mov    -0x8(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x8(%rbp)
jmp    1178 <main+0x38>
cmpq   $0x0,-0x10(%rbp)
je     11c5 <main+0x85>
mov    -0x10(%rbp),%rdi
call   1030 <free@plt>
xor    %eax,%eax
add    $0x10,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %r14
push   %rbx
push   %rax
mov    $0x40000000,%edi
mov    $0x1,%esi
call   1050 <calloc@plt>
mov    %rax,%r14
mov    $0xf4240,%edi
call   1060 <usleep@plt>
lea    0xe99(%rip),%rbx
mov    %rbx,%rdi
mov    $0x9,%esi
call   1040 <printf@plt>
mov    $0xf4240,%edi
call   1060 <usleep@plt>
mov    %rbx,%rdi
mov    $0x8,%esi
call   1040 <printf@plt>
mov    $0xf4240,%edi
call   1060 <usleep@plt>
mov    %rbx,%rdi
mov    $0x7,%esi
call   1040 <printf@plt>
mov    $0xf4240,%edi
call   1060 <usleep@plt>
mov    %rbx,%rdi
mov    $0x6,%esi
call   1040 <printf@plt>
mov    $0xf4240,%edi
call   1060 <usleep@plt>
mov    %rbx,%rdi
mov    $0x5,%esi
call   1040 <printf@plt>
mov    $0xf4240,%edi
call   1060 <usleep@plt>
mov    %rbx,%rdi
mov    $0x4,%esi
call   1040 <printf@plt>
mov    $0xf4240,%edi
call   1060 <usleep@plt>
mov    %rbx,%rdi
mov    $0x3,%esi
call   1040 <printf@plt>
mov    $0xf4240,%edi
call   1060 <usleep@plt>
mov    %rbx,%rdi
mov    $0x2,%esi
call   1040 <printf@plt>
mov    $0xf4240,%edi
call   1060 <usleep@plt>
mov    %rbx,%rdi
mov    $0x1,%esi
call   1040 <printf@plt>
mov    $0xf4240,%edi
call   1060 <usleep@plt>
mov    %rbx,%rdi
xor    %esi,%esi
call   1040 <printf@plt>
test   %r14,%r14
je     124d <main+0x10d>
mov    %r14,%rdi
call   1030 <free@plt>
xor    %eax,%eax
add    $0x8,%rsp
pop    %rbx
pop    %r14
ret

LLVM IR (-O0):
@.str = [24 x i8] c"%02d seconds remaining\0A\00"
define i32 @main() {
%1 = alloca i32
%2 = alloca i32
%3 = alloca i8*
store i32 0, i32* %1
store i32 0, i32* %2
store i8* null, i8** %3
%4 = call i64 @calloc(i32 1073741824, i32 1)
%5 = inttoptr i64 %4 to i8*
store i8* %5, i8** %3
store i32 0, i32* %2
br label %6
6: ; preds = %15, %0
%7 = load i32, i32* %2
%8 = icmp slt i32 %7, 10
br i1 %8, label %9, label %18
9: ; preds = %6
%10 = call i32 @usleep(i32 1000000)
%11 = load i32, i32* %2
%12 = sub nsw i32 10, %11
%13 = sub nsw i32 %12, 1
%14 = call i32 @printf(i8* getelementptr inbounds ([24 x i8], [24 x i8]* @.str, i64 0, i64 0), i32 %13)
br label %15
15: ; preds = %9
%16 = load i32, i32* %2
%17 = add nsw i32 %16, 1
store i32 %17, i32* %2
br label %6
18: ; preds = %6
%19 = load i8*, i8** %3
%20 = icmp ne i8* %19, null
br i1 %20, label %21, label %24
21: ; preds = %18
%22 = load i8*, i8** %3
%23 = call i32 @free(i8* %22)
br label %24
24: ; preds = %21, %18
ret i32 0
}

LLVM IR (-O2):
@.str = [24 x i8] c"%02d seconds remaining\0A\00"
define i32 @main() {
%1 = tail call i64 @calloc(i32 1073741824, i32 1)
%2 = tail call i32 @usleep(i32 1000000)
%3 = tail call i32 @printf(i8* getelementptr inbounds ([24 x i8], [24 x i8]* @.str, i64 0, i64 0), i32 9)
%4 = tail call i32 @usleep(i32 1000000)
%5 = tail call i32 @printf(i8* getelementptr inbounds ([24 x i8], [24 x i8]* @.str, i64 0, i64 0), i32 8)
%6 = tail call i32 @usleep(i32 1000000)
%7 = tail call i32 @printf(i8* getelementptr inbounds ([24 x i8], [24 x i8]* @.str, i64 0, i64 0), i32 7)
%8 = tail call i32 @usleep(i32 1000000)
%9 = tail call i32 @printf(i8* getelementptr inbounds ([24 x i8], [24 x i8]* @.str, i64 0, i64 0), i32 6)
%10 = tail call i32 @usleep(i32 1000000)
%11 = tail call i32 @printf(i8* getelementptr inbounds ([24 x i8], [24 x i8]* @.str, i64 0, i64 0), i32 5)
%12 = tail call i32 @usleep(i32 1000000)
%13 = tail call i32 @printf(i8* getelementptr inbounds ([24 x i8], [24 x i8]* @.str, i64 0, i64 0), i32 4)
%14 = tail call i32 @usleep(i32 1000000)
%15 = tail call i32 @printf(i8* getelementptr inbounds ([24 x i8], [24 x i8]* @.str, i64 0, i64 0), i32 3)
%16 = tail call i32 @usleep(i32 1000000)
%17 = tail call i32 @printf(i8* getelementptr inbounds ([24 x i8], [24 x i8]* @.str, i64 0, i64 0), i32 2)
%18 = tail call i32 @usleep(i32 1000000)
%19 = tail call i32 @printf(i8* getelementptr inbounds ([24 x i8], [24 x i8]* @.str, i64 0, i64 0), i32 1)
%20 = tail call i32 @usleep(i32 1000000)
%21 = tail call i32 @printf(i8* getelementptr inbounds ([24 x i8], [24 x i8]* @.str, i64 0, i64 0), i32 0)
%22 = icmp eq i64 %1, 0
br i1 %22, label %26, label %23
23: ; preds = %0
%24 = inttoptr i64 %1 to i8*
%25 = tail call i32 @free(i8* %24)
br label %26
26: ; preds = %23, %0
ret i32 0
}