#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 O_CREAT;
int O_RDONLY;
int /*<<< orphan*/ close(int);
int /*<<< orphan*/ errno;
int /*<<< orphan*/ fprintf(int /*<<< orphan*/, char *, ...);
int open(char *, int, int);
int /*<<< orphan*/ stderr;
char *strerror(int /*<<< orphan*/);
int main(int argc, char *argv[]) {
  if (argc < 2) {
    fprintf(stderr, "USAGE:\t%s file1 [file2...]\n", argv[0]);
    fprintf(stderr,
            "\tCreate files with the specified names if they do not exist.\n");
    return 1;
  };
  int i;
  for (i = 1; i < argc; i++) {
    int fd = open(argv[i], O_CREAT | O_RDONLY, 0644);
    if (fd == -1) {
      fprintf(stderr, "%s: cannot open/create %s: %s\n", argv[0], argv[i],
              strerror(errno));
      return 1;
    };
    close(fd);
  };
  return 0;
}


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)
cmpl   $0x2,-0x8(%rbp)
jge    11a1 <main+0x61>
mov    0x2e69(%rip),%rax
mov    (%rax),%edi
mov    -0x10(%rbp),%rax
mov    (%rax),%rdx
lea    0xe89(%rip),%rsi
mov    $0x0,%al
call   1040 <fprintf@plt>
mov    0x2e4b(%rip),%rax
mov    (%rax),%edi
lea    0xe8e(%rip),%rsi
mov    $0x0,%al
call   1040 <fprintf@plt>
movl   $0x1,-0x4(%rbp)
jmp    1263 <main+0x123>
movl   $0x1,-0x14(%rbp)
mov    -0x14(%rbp),%eax
cmp    -0x8(%rbp),%eax
jge    125c <main+0x11c>
mov    -0x10(%rbp),%rax
movslq -0x14(%rbp),%rcx
mov    (%rax,%rcx,8),%rdi
mov    0x2e31(%rip),%rax
mov    (%rax),%esi
mov    0x2e10(%rip),%rax
or     (%rax),%esi
mov    $0x1a4,%edx
call   1050 <open@plt>
mov    %eax,-0x18(%rbp)
cmpl   $0xffffffff,-0x18(%rbp)
jne    1246 <main+0x106>
mov    0x2de0(%rip),%rax
mov    (%rax),%eax
mov    %eax,-0x2c(%rbp)
mov    -0x10(%rbp),%rax
mov    (%rax),%rax
mov    %rax,-0x28(%rbp)
mov    -0x10(%rbp),%rax
movslq -0x14(%rbp),%rcx
mov    (%rax,%rcx,8),%rax
mov    %rax,-0x20(%rbp)
mov    0x2db1(%rip),%rax
mov    (%rax),%edi
call   1060 <strerror@plt>
mov    -0x2c(%rbp),%edi
mov    -0x28(%rbp),%rdx
mov    -0x20(%rbp),%rcx
mov    %rax,%r8
lea    0xe27(%rip),%rsi
mov    $0x0,%al
call   1040 <fprintf@plt>
movl   $0x1,-0x4(%rbp)
jmp    1263 <main+0x123>
mov    -0x18(%rbp),%edi
call   1030 <close@plt>
mov    -0x14(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x14(%rbp)
jmp    11a8 <main+0x68>
movl   $0x0,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbp
push   %r15
push   %r14
push   %r12
push   %rbx
mov    %rsi,%rbx
cmp    $0x2,%edi
jge    1181 <main+0x41>
mov    0x2e79(%rip),%rbp
mov    0x0(%rbp),%edi
mov    (%rbx),%rdx
lea    0xe9c(%rip),%rsi
xor    %eax,%eax
call   1040 <fprintf@plt>
mov    0x0(%rbp),%edi
lea    0xea7(%rip),%rsi
xor    %eax,%eax
call   1040 <fprintf@plt>
jmp    1207 <main+0xc7>
mov    %edi,%r14d
mov    $0x1,%ebp
mov    0x2e68(%rip),%r15
mov    0x2e49(%rip),%r12
nopw   0x0(%rax,%rax,1)
mov    (%rbx,%rbp,8),%rdi
mov    (%r12),%esi
or     (%r15),%esi
mov    $0x1a4,%edx
call   1050 <open@plt>
cmp    $0xffffffff,%eax
je     11ce <main+0x8e>
mov    %eax,%edi
call   1030 <close@plt>
add    $0x1,%rbp
cmp    %rbp,%r14
jne    11a0 <main+0x60>
xor    %eax,%eax
jmp    120c <main+0xcc>
mov    0x2dfb(%rip),%rax
mov    (%rax),%r15d
mov    (%rbx),%r14
mov    (%rbx,%rbp,8),%rbx
mov    0x2de2(%rip),%rax
mov    (%rax),%edi
call   1060 <strerror@plt>
lea    0xe66(%rip),%rsi
mov    %r15d,%edi
mov    %r14,%rdx
mov    %rbx,%rcx
mov    %rax,%r8
xor    %eax,%eax
call   1040 <fprintf@plt>
mov    $0x1,%eax
pop    %rbx
pop    %r12
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
@stderr = global i32 0
@.str = [28 x i8] c"USAGE:\09%s file1 [file2...]\0A\00"
@.str.1 = [62 x i8] c"\09Create files with the specified names if they do not exist.\0A\00"
@O_CREAT = global i32 0
@O_RDONLY = global i32 0
@.str.2 = [31 x i8] c"%s: cannot open/create %s: %s\0A\00"
@errno = global i32 0
define i32 @main(i32 %0, i8** %1) {
%3 = alloca i32
%4 = alloca i32
%5 = alloca i8**
%6 = alloca i32
%7 = alloca i32
store i32 0, i32* %3
store i32 %0, i32* %4
store i8** %1, i8*** %5
%8 = load i32, i32* %4
%9 = icmp slt i32 %8, 2
br i1 %9, label %10, label %18
10: ; preds = %2
%11 = load i32, i32* @stderr
%12 = load i8**, i8*** %5
%13 = getelementptr inbounds i8*, i8** %12, i64 0
%14 = load i8*, i8** %13
%15 = call i32 (i32, i8*, ...) @fprintf(i32 %11, i8* getelementptr inbounds ([28 x i8], [28 x i8]* @.str, i64 0, i64 0), i8* %14)
%16 = load i32, i32* @stderr
%17 = call i32 (i32, i8*, ...) @fprintf(i32 %16, i8* getelementptr inbounds ([62 x i8], [62 x i8]* @.str.1, i64 0, i64 0))
store i32 1, i32* %3
br label %55
18: ; preds = %2
store i32 1, i32* %6
br label %19
19: ; preds = %51, %18
%20 = load i32, i32* %6
%21 = load i32, i32* %4
%22 = icmp slt i32 %20, %21
br i1 %22, label %23, label %54
23: ; preds = %19
%24 = load i8**, i8*** %5
%25 = load i32, i32* %6
%26 = sext i32 %25 to i64
%27 = getelementptr inbounds i8*, i8** %24, i64 %26
%28 = load i8*, i8** %27
%29 = load i32, i32* @O_CREAT
%30 = load i32, i32* @O_RDONLY
%31 = or i32 %29, %30
%32 = call i32 @open(i8* %28, i32 %31, i32 420)
store i32 %32, i32* %7
%33 = load i32, i32* %7
%34 = icmp eq i32 %33, -1
br i1 %34, label %35, label %48
35: ; preds = %23
%36 = load i32, i32* @stderr
%37 = load i8**, i8*** %5
%38 = getelementptr inbounds i8*, i8** %37, i64 0
%39 = load i8*, i8** %38
%40 = load i8**, i8*** %5
%41 = load i32, i32* %6
%42 = sext i32 %41 to i64
%43 = getelementptr inbounds i8*, i8** %40, i64 %42
%44 = load i8*, i8** %43
%45 = load i32, i32* @errno
%46 = call i8* @strerror(i32 %45)
%47 = call i32 (i32, i8*, ...) @fprintf(i32 %36, i8* getelementptr inbounds ([31 x i8], [31 x i8]* @.str.2, i64 0, i64 0), i8* %39, i8* %44, i8* %46)
store i32 1, i32* %3
br label %55
48: ; preds = %23
%49 = load i32, i32* %7
%50 = call i32 @close(i32 %49)
br label %51
51: ; preds = %48
%52 = load i32, i32* %6
%53 = add nsw i32 %52, 1
store i32 %53, i32* %6
br label %19
54: ; preds = %19
store i32 0, i32* %3
br label %55
55: ; preds = %54, %35, %10
%56 = load i32, i32* %3
ret i32 %56
}

LLVM IR (-O2):
@stderr = global i32 0
@.str = [28 x i8] c"USAGE:\09%s file1 [file2...]\0A\00"
@.str.1 = [62 x i8] c"\09Create files with the specified names if they do not exist.\0A\00"
@O_CREAT = global i32 0
@O_RDONLY = global i32 0
@.str.2 = [31 x i8] c"%s: cannot open/create %s: %s\0A\00"
@errno = global i32 0
define i32 @main(i32 %0, i8** nocapture %1) {
%3 = icmp slt i32 %0, 2
br i1 %3, label %6, label %4
4: ; preds = %2
%5 = zext i32 %0 to i64
br label %12
6: ; preds = %2
%7 = load i32, i32* @stderr
%8 = load i8*, i8** %1
%9 = tail call i32 (i32, i8*, ...) @fprintf(i32 %7, i8* getelementptr inbounds ([28 x i8], [28 x i8]* @.str, i64 0, i64 0), i8* %8)
%10 = load i32, i32* @stderr
%11 = tail call i32 (i32, i8*, ...) @fprintf(i32 %10, i8* getelementptr inbounds ([62 x i8], [62 x i8]* @.str.1, i64 0, i64 0))
br label %34
12: ; preds = %4, %30
%13 = phi i64 [ 1, %4 ], [ %32, %30 ]
%14 = getelementptr inbounds i8*, i8** %1, i64 %13
%15 = load i8*, i8** %14
%16 = load i32, i32* @O_CREAT
%17 = load i32, i32* @O_RDONLY
%18 = or i32 %17, %16
%19 = tail call i32 @open(i8* %15, i32 %18, i32 420)
%20 = icmp eq i32 %19, -1
br i1 %20, label %21, label %30
21: ; preds = %12
%22 = and i64 %13, 4294967295
%23 = getelementptr inbounds i8*, i8** %1, i64 %22
%24 = load i32, i32* @stderr
%25 = load i8*, i8** %1
%26 = load i8*, i8** %23
%27 = load i32, i32* @errno
%28 = tail call i8* @strerror(i32 %27)
%29 = tail call i32 (i32, i8*, ...) @fprintf(i32 %24, i8* getelementptr inbounds ([31 x i8], [31 x i8]* @.str.2, i64 0, i64 0), i8* %25, i8* %26, i8* %28)
br label %34
30: ; preds = %12
%31 = tail call i32 @close(i32 %19)
%32 = add nuw nsw i64 %13, 1
%33 = icmp eq i64 %32, %5
br i1 %33, label %34, label %12
34: ; preds = %30, %21, %6
%35 = phi i32 [ 1, %6 ], [ 1, %21 ], [ 0, %30 ]
ret i32 %35
}