#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 unsigned int time_t;
struct stat {
  unsigned int st_mtime;
};

/* Variables and functions */
int /*<<< orphan*/ assert(int);
int /*<<< orphan*/ printf(char *, unsigned int);
unsigned int sleep(int);
int /*<<< orphan*/ stat(char *, struct stat *);
int /*<<< orphan*/ touch(char *, char *);
int main(int argc, char *argv[]) {
  struct stat st;
  char path[] = "/tmp/foo";
  time_t m1, m2;
  unsigned int t;
  touch(path, "hello\n");
  assert(!stat(path, &st));
  m1 = st.st_mtime;
  t = sleep(2);
  touch(path, "hello, world!\n");
  assert(!stat(path, &st));
  m2 = st.st_mtime;
  printf("Sleep remaining: %lu\n", t);
  printf("Elapsed modtime=%lu\n", m2 - m1);
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
mov    %edi,-0x4(%rbp)
mov    %rsi,-0x10(%rbp)
mov    0xe9a(%rip),%rax
mov    %rax,-0x21(%rbp)
mov    0xe98(%rip),%al
mov    %al,-0x19(%rbp)
lea    -0x21(%rbp),%rdi
lea    0xe8b(%rip),%rsi
call   1030 <touch@plt>
lea    -0x21(%rbp),%rdi
lea    -0x18(%rbp),%rsi
call   1060 <stat@plt>
cmp    $0x0,%eax
setne  %al
xor    $0xff,%al
and    $0x1,%al
movzbl %al,%edi
call   1050 <assert@plt>
mov    -0x18(%rbp),%eax
mov    %eax,-0x28(%rbp)
mov    $0x2,%edi
call   1070 <sleep@plt>
mov    %eax,-0x30(%rbp)
lea    -0x21(%rbp),%rdi
lea    0xe50(%rip),%rsi
call   1030 <touch@plt>
lea    -0x21(%rbp),%rdi
lea    -0x18(%rbp),%rsi
call   1060 <stat@plt>
cmp    $0x0,%eax
setne  %al
xor    $0xff,%al
and    $0x1,%al
movzbl %al,%edi
call   1050 <assert@plt>
mov    -0x18(%rbp),%eax
mov    %eax,-0x2c(%rbp)
mov    -0x30(%rbp),%esi
lea    0xe2b(%rip),%rdi
call   1040 <printf@plt>
mov    -0x2c(%rbp),%esi
sub    -0x28(%rbp),%esi
lea    0xe2f(%rip),%rdi
call   1040 <printf@plt>
xor    %eax,%eax
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbp
push   %r15
push   %r14
push   %rbx
sub    $0x18,%rsp
movabs $0x6f6f662f706d742f,%rax
66 6f 6f
mov    %rax,0x8(%rsp)
movb   $0x0,0x10(%rsp)
lea    0xe94(%rip),%rsi
lea    0x8(%rsp),%rbx
mov    %rbx,%rdi
call   1030 <touch@plt>
mov    %rsp,%r14
mov    %rbx,%rdi
mov    %r14,%rsi
call   1060 <stat@plt>
xor    %edi,%edi
test   %eax,%eax
sete   %dil
call   1050 <assert@plt>
mov    (%rsp),%r15d
mov    $0x2,%edi
call   1070 <sleep@plt>
mov    %eax,%ebp
lea    0xe5c(%rip),%rsi
mov    %rbx,%rdi
call   1030 <touch@plt>
mov    %rbx,%rdi
mov    %r14,%rsi
call   1060 <stat@plt>
xor    %edi,%edi
test   %eax,%eax
sete   %dil
call   1050 <assert@plt>
mov    (%rsp),%ebx
sub    %r15d,%ebx
lea    0xe3e(%rip),%rdi
mov    %ebp,%esi
call   1040 <printf@plt>
lea    0xe46(%rip),%rdi
mov    %ebx,%esi
call   1040 <printf@plt>
xor    %eax,%eax
add    $0x18,%rsp
pop    %rbx
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
%struct.stat = type { i32 }
@__const.main.path = [9 x i8] c"/tmp/foo\00"
@.str = [7 x i8] c"hello\0A\00"
@.str.1 = [15 x i8] c"hello, world!\0A\00"
@.str.2 = [22 x i8] c"Sleep remaining: %lu\0A\00"
@.str.3 = [21 x i8] c"Elapsed modtime=%lu\0A\00"
define i32 @main(i32 %0, i8** %1) {
%3 = alloca i32
%4 = alloca i8**
%5 = alloca %struct.stat
%6 = alloca [9 x i8]
%7 = alloca i32
%8 = alloca i32
%9 = alloca i32
store i32 %0, i32* %3
store i8** %1, i8*** %4
%10 = bitcast [9 x i8]* %6 to i8*
%11 = getelementptr inbounds [9 x i8], [9 x i8]* %6, i64 0, i64 0
%12 = call i32 @touch(i8* %11, i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str, i64 0, i64 0))
%13 = getelementptr inbounds [9 x i8], [9 x i8]* %6, i64 0, i64 0
%14 = call i32 @stat(i8* %13, %struct.stat* %5)
%15 = icmp ne i32 %14, 0
%16 = xor i1 %15, true
%17 = zext i1 %16 to i32
%18 = call i32 @assert(i32 %17)
%19 = getelementptr inbounds %struct.stat, %struct.stat* %5, i32 0, i32 0
%20 = load i32, i32* %19
store i32 %20, i32* %7
%21 = call i32 @sleep(i32 2)
store i32 %21, i32* %9
%22 = getelementptr inbounds [9 x i8], [9 x i8]* %6, i64 0, i64 0
%23 = call i32 @touch(i8* %22, i8* getelementptr inbounds ([15 x i8], [15 x i8]* @.str.1, i64 0, i64 0))
%24 = getelementptr inbounds [9 x i8], [9 x i8]* %6, i64 0, i64 0
%25 = call i32 @stat(i8* %24, %struct.stat* %5)
%26 = icmp ne i32 %25, 0
%27 = xor i1 %26, true
%28 = zext i1 %27 to i32
%29 = call i32 @assert(i32 %28)
%30 = getelementptr inbounds %struct.stat, %struct.stat* %5, i32 0, i32 0
%31 = load i32, i32* %30
store i32 %31, i32* %8
%32 = load i32, i32* %9
%33 = call i32 @printf(i8* getelementptr inbounds ([22 x i8], [22 x i8]* @.str.2, i64 0, i64 0), i32 %32)
%34 = load i32, i32* %8
%35 = load i32, i32* %7
%36 = sub i32 %34, %35
%37 = call i32 @printf(i8* getelementptr inbounds ([21 x i8], [21 x i8]* @.str.3, i64 0, i64 0), i32 %36)
ret i32 0
}

LLVM IR (-O2):
%struct.stat = type { i32 }
@__const.main.path = [9 x i8] c"/tmp/foo\00"
@.str = [7 x i8] c"hello\0A\00"
@.str.1 = [15 x i8] c"hello, world!\0A\00"
@.str.2 = [22 x i8] c"Sleep remaining: %lu\0A\00"
@.str.3 = [21 x i8] c"Elapsed modtime=%lu\0A\00"
define i32 @main(i32 %0, i8** nocapture readnone %1) {
%3 = alloca %struct.stat
%4 = alloca [9 x i8]
%5 = bitcast %struct.stat* %3 to i8*
%6 = getelementptr inbounds [9 x i8], [9 x i8]* %4, i64 0, i64 0
%7 = call i32 @touch(i8* %6, i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str, i64 0, i64 0))
%8 = call i32 @stat(i8* %6, %struct.stat* %3)
%9 = icmp eq i32 %8, 0
%10 = zext i1 %9 to i32
%11 = call i32 @assert(i32 %10)
%12 = getelementptr inbounds %struct.stat, %struct.stat* %3, i64 0, i32 0
%13 = load i32, i32* %12
%14 = call i32 @sleep(i32 2)
%15 = call i32 @touch(i8* %6, i8* getelementptr inbounds ([15 x i8], [15 x i8]* @.str.1, i64 0, i64 0))
%16 = call i32 @stat(i8* %6, %struct.stat* %3)
%17 = icmp eq i32 %16, 0
%18 = zext i1 %17 to i32
%19 = call i32 @assert(i32 %18)
%20 = load i32, i32* %12
%21 = call i32 @printf(i8* getelementptr inbounds ([22 x i8], [22 x i8]* @.str.2, i64 0, i64 0), i32 %14)
%22 = sub i32 %20, %13
%23 = call i32 @printf(i8* getelementptr inbounds ([21 x i8], [21 x i8]* @.str.3, i64 0, i64 0), i32 %22)
ret i32 0
}