#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 */
struct timeval {
  int dummy;
};

/* Variables and functions */
int EXIT_SUCCESS;
int O_CREAT;
int O_NOFOLLOW;
int O_WRONLY;
int /*<<< orphan*/ close(int);
int /*<<< orphan*/ err(int, char *);
int /*<<< orphan*/ exit(int);
int gettimeofday(struct timeval *, int /*<<< orphan*/ *);
int open(char *, int, int);
int /*<<< orphan*/ utimes(char *, struct timeval *);
int /*<<< orphan*/ warn(char *, int);
int main(void) {
  int ch, exit_status, fd;
  char name[2];
  struct timeval when[2];
  exit_status = EXIT_SUCCESS;
  name[1] = '\0';
  if (gettimeofday(when, NULL) == -1)
    err(1, "gettimeofday failed");
  when[1] = when[0];
  for (ch = 1; ch < 256; ch++) {
    if (ch == '/' || ch == '.')
      continue;
    name[0] = ch;
    fd = open(name, O_CREAT | O_NOFOLLOW | O_WRONLY, 0666);
    if (fd < 0) {
      warn("open failed '%c'", ch);
      exit_status = 1;
    } else {
      utimes(name, when);
      close(fd);
    }
  }
  exit(exit_status);
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
movl   $0x0,-0x4(%rbp)
mov    0x2e4a(%rip),%rax
mov    (%rax),%eax
mov    %eax,-0xc(%rbp)
movb   $0x0,-0x11(%rbp)
lea    -0x20(%rbp),%rdi
xor    %eax,%eax
mov    %eax,%esi
call   1040 <gettimeofday@plt>
cmp    $0xffffffff,%eax
jne    11b6 <main+0x46>
mov    $0x1,%edi
lea    0xe4f(%rip),%rsi
call   1070 <err@plt>
mov    -0x20(%rbp),%eax
mov    %eax,-0x1c(%rbp)
movl   $0x1,-0x8(%rbp)
cmpl   $0x100,-0x8(%rbp)
jge    1268 <main+0xf8>
cmpl   $0x2f,-0x8(%rbp)
je     11e4 <main+0x74>
cmpl   $0x2e,-0x8(%rbp)
jne    11e9 <main+0x79>
jmp    125a <main+0xea>
mov    -0x8(%rbp),%eax
mov    %al,-0x12(%rbp)
lea    -0x12(%rbp),%rdi
mov    0x2dfe(%rip),%rax
mov    (%rax),%esi
mov    0x2ded(%rip),%rax
or     (%rax),%esi
mov    0x2db4(%rip),%rax
or     (%rax),%esi
mov    $0x1b6,%edx
call   1080 <open@plt>
mov    %eax,-0x10(%rbp)
cmpl   $0x0,-0x10(%rbp)
jge    1240 <main+0xd0>
mov    -0x8(%rbp),%esi
lea    0xde5(%rip),%rdi
call   1030 <warn@plt>
movl   $0x1,-0xc(%rbp)
jmp    1255 <main+0xe5>
lea    -0x12(%rbp),%rdi
lea    -0x20(%rbp),%rsi
call   1060 <utimes@plt>
mov    -0x10(%rbp),%edi
call   1050 <close@plt>
jmp    125a <main+0xea>
mov    -0x8(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x8(%rbp)
jmp    11c3 <main+0x53>
mov    -0xc(%rbp),%edi
call   1090 <exit@plt>

x86 assembly (clang, -O2):
<main>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
sub    $0x18,%rsp
mov    0x2e4b(%rip),%rax
mov    (%rax),%eax
mov    %eax,0xc(%rsp)
movb   $0x0,0xb(%rsp)
lea    0x10(%rsp),%rdi
xor    %esi,%esi
call   1040 <gettimeofday@plt>
cmp    $0xffffffff,%eax
jne    11b2 <main+0x42>
lea    0xe58(%rip),%rsi
mov    $0x1,%edi
call   1070 <err@plt>
mov    0x10(%rsp),%eax
mov    %eax,0x14(%rsp)
mov    $0x1,%ebp
mov    0x2e32(%rip),%r15
mov    0x2e23(%rip),%r14
mov    0x2dec(%rip),%r12
lea    0xa(%rsp),%r13
jmp    1201 <main+0x91>
nopl   0x0(%rax,%rax,1)
mov    %eax,%ebx
mov    %r13,%rdi
lea    0x10(%rsp),%rsi
call   1060 <utimes@plt>
mov    %ebx,%edi
call   1050 <close@plt>
add    $0x1,%ebp
cmp    $0x100,%ebp
je     1245 <main+0xd5>
mov    %ebp,%eax
and    $0x7ffffffe,%eax
cmp    $0x2e,%eax
je     11f6 <main+0x86>
mov    %bpl,0xa(%rsp)
mov    (%r14),%esi
or     (%r15),%esi
or     (%r12),%esi
mov    %r13,%rdi
mov    $0x1b6,%edx
call   1080 <open@plt>
test   %eax,%eax
jns    11e0 <main+0x70>
lea    0xde0(%rip),%rdi
mov    %ebp,%esi
call   1030 <warn@plt>
movl   $0x1,0xc(%rsp)
jmp    11f6 <main+0x86>
mov    0xc(%rsp),%edi
call   1090 <exit@plt>

LLVM IR (-O0):
%struct.timeval = type { i32 }
@EXIT_SUCCESS = global i32 0
@.str = [20 x i8] c"gettimeofday failed\00"
@O_CREAT = global i32 0
@O_NOFOLLOW = global i32 0
@O_WRONLY = global i32 0
@.str.1 = [17 x i8] c"open failed '%c'\00"
define i32 @main() {
%1 = alloca i32
%2 = alloca i32
%3 = alloca i32
%4 = alloca i32
%5 = alloca [2 x i8]
%6 = alloca [2 x %struct.timeval]
store i32 0, i32* %1
%7 = load i32, i32* @EXIT_SUCCESS
store i32 %7, i32* %3
%8 = getelementptr inbounds [2 x i8], [2 x i8]* %5, i64 0, i64 1
store i8 0, i8* %8
%9 = getelementptr inbounds [2 x %struct.timeval], [2 x %struct.timeval]* %6, i64 0, i64 0
%10 = call i32 @gettimeofday(%struct.timeval* %9, i32* null)
%11 = icmp eq i32 %10, -1
br i1 %11, label %12, label %14
12: ; preds = %0
%13 = call i32 @err(i32 1, i8* getelementptr inbounds ([20 x i8], [20 x i8]* @.str, i64 0, i64 0))
br label %14
14: ; preds = %12, %0
%15 = getelementptr inbounds [2 x %struct.timeval], [2 x %struct.timeval]* %6, i64 0, i64 1
%16 = getelementptr inbounds [2 x %struct.timeval], [2 x %struct.timeval]* %6, i64 0, i64 0
%17 = bitcast %struct.timeval* %15 to i8*
%18 = bitcast %struct.timeval* %16 to i8*
store i32 1, i32* %2
br label %19
19: ; preds = %52, %14
%20 = load i32, i32* %2
%21 = icmp slt i32 %20, 256
br i1 %21, label %22, label %55
22: ; preds = %19
%23 = load i32, i32* %2
%24 = icmp eq i32 %23, 47
br i1 %24, label %28, label %25
25: ; preds = %22
%26 = load i32, i32* %2
%27 = icmp eq i32 %26, 46
br i1 %27, label %28, label %29
28: ; preds = %25, %22
br label %52
29: ; preds = %25
%30 = load i32, i32* %2
%31 = trunc i32 %30 to i8
%32 = getelementptr inbounds [2 x i8], [2 x i8]* %5, i64 0, i64 0
store i8 %31, i8* %32
%33 = getelementptr inbounds [2 x i8], [2 x i8]* %5, i64 0, i64 0
%34 = load i32, i32* @O_CREAT
%35 = load i32, i32* @O_NOFOLLOW
%36 = or i32 %34, %35
%37 = load i32, i32* @O_WRONLY
%38 = or i32 %36, %37
%39 = call i32 @open(i8* %33, i32 %38, i32 438)
store i32 %39, i32* %4
%40 = load i32, i32* %4
%41 = icmp slt i32 %40, 0
br i1 %41, label %42, label %45
42: ; preds = %29
%43 = load i32, i32* %2
%44 = call i32 @warn(i8* getelementptr inbounds ([17 x i8], [17 x i8]* @.str.1, i64 0, i64 0), i32 %43)
store i32 1, i32* %3
br label %51
45: ; preds = %29
%46 = getelementptr inbounds [2 x i8], [2 x i8]* %5, i64 0, i64 0
%47 = getelementptr inbounds [2 x %struct.timeval], [2 x %struct.timeval]* %6, i64 0, i64 0
%48 = call i32 @utimes(i8* %46, %struct.timeval* %47)
%49 = load i32, i32* %4
%50 = call i32 @close(i32 %49)
br label %51
51: ; preds = %45, %42
br label %52
52: ; preds = %51, %28
%53 = load i32, i32* %2
%54 = add nsw i32 %53, 1
store i32 %54, i32* %2
br label %19
55: ; preds = %19
%56 = load i32, i32* %3
%57 = call i32 @exit(i32 %56)
unreachable
}

LLVM IR (-O2):
%struct.timeval = type { i32 }
@EXIT_SUCCESS = global i32 0
@.str = [20 x i8] c"gettimeofday failed\00"
@O_CREAT = global i32 0
@O_NOFOLLOW = global i32 0
@O_WRONLY = global i32 0
@.str.1 = [17 x i8] c"open failed '%c'\00"
define i32 @main() {
%1 = alloca [2 x i8]
%2 = alloca [2 x %struct.timeval]
%3 = getelementptr inbounds [2 x i8], [2 x i8]* %1, i64 0, i64 0
%4 = bitcast [2 x %struct.timeval]* %2 to i8*
%5 = load i32, i32* @EXIT_SUCCESS
%6 = getelementptr inbounds [2 x i8], [2 x i8]* %1, i64 0, i64 1
store i8 0, i8* %6
%7 = getelementptr inbounds [2 x %struct.timeval], [2 x %struct.timeval]* %2, i64 0, i64 0
%8 = call i32 @gettimeofday(%struct.timeval* %7, i32* null)
%9 = icmp eq i32 %8, -1
br i1 %9, label %10, label %12
10: ; preds = %0
%11 = tail call i32 @err(i32 1, i8* getelementptr inbounds ([20 x i8], [20 x i8]* @.str, i64 0, i64 0))
br label %12
12: ; preds = %10, %0
%13 = getelementptr inbounds [2 x %struct.timeval], [2 x %struct.timeval]* %2, i64 0, i64 0, i32 0
%14 = getelementptr inbounds [2 x %struct.timeval], [2 x %struct.timeval]* %2, i64 0, i64 1, i32 0
%15 = load i32, i32* %13
store i32 %15, i32* %14
br label %16
16: ; preds = %12, %35
%17 = phi i32 [ 1, %12 ], [ %37, %35 ]
%18 = phi i32 [ %5, %12 ], [ %36, %35 ]
%19 = and i32 %17, 2147483646
%20 = icmp eq i32 %19, 46
br i1 %20, label %35, label %21
21: ; preds = %16
%22 = trunc i32 %17 to i8
store i8 %22, i8* %3
%23 = load i32, i32* @O_CREAT
%24 = load i32, i32* @O_NOFOLLOW
%25 = or i32 %24, %23
%26 = load i32, i32* @O_WRONLY
%27 = or i32 %25, %26
%28 = call i32 @open(i8* %3, i32 %27, i32 438)
%29 = icmp slt i32 %28, 0
br i1 %29, label %30, label %32
30: ; preds = %21
%31 = tail call i32 @warn(i8* getelementptr inbounds ([17 x i8], [17 x i8]* @.str.1, i64 0, i64 0), i32 %17)
br label %35
32: ; preds = %21
%33 = call i32 @utimes(i8* %3, %struct.timeval* %7)
%34 = tail call i32 @close(i32 %28)
br label %35
35: ; preds = %30, %32, %16
%36 = phi i32 [ %18, %16 ], [ 1, %30 ], [ %18, %32 ]
%37 = add nuw nsw i32 %17, 1
%38 = icmp eq i32 %37, 256
br i1 %38, label %39, label %16
39: ; preds = %35
%40 = tail call i32 @exit(i32 %36)
unreachable
}