#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*/ FILE;

/* Variables and functions */
int /*<<< orphan*/ exit(int);
int /*<<< orphan*/ fclose(int /*<<< orphan*/ *);
int /*<<< orphan*/ fflush(int /*<<< orphan*/ *);
int /*<<< orphan*/ *fopen(char *, char *);
int /*<<< orphan*/ fprintf(int /*<<< orphan*/, char *, char *, ...);
int /*<<< orphan*/ fputs(char *, int /*<<< orphan*/ *);
int /*<<< orphan*/ stderr;
int main(int argc, char *argv[]) {
  FILE *f;
  if (argc < 3) {
    fprintf(stderr, "usage: %s file string...\n", argv[0]);
    exit(1);
  }
  if ((f = fopen(argv[1], "w")) == NULL) {
    fprintf(stderr, "%s:could not open %s for writing.\n", argv[0], argv[1]);
    exit(2);
  }
  argc -= 2;
  argv += 2;
  while (argc--) {
    fputs(*argv++, f);
    if (argc)
      fputs(" ", f);
  }
  fputs("\n", f);
  fflush(f);
  fclose(f);
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
movl   $0x0,-0x4(%rbp)
mov    %edi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
cmpl   $0x3,-0x8(%rbp)
jge    11a8 <main+0x48>
mov    0x2e59(%rip),%rax
mov    (%rax),%edi
mov    -0x10(%rbp),%rax
mov    (%rax),%rdx
lea    0xe69(%rip),%rsi
mov    $0x0,%al
call   1050 <fprintf@plt>
mov    $0x1,%edi
call   1080 <exit@plt>
mov    -0x10(%rbp),%rax
mov    0x8(%rax),%rdi
lea    0xe63(%rip),%rsi
call   1070 <fopen@plt>
mov    %rax,-0x18(%rbp)
cmp    $0x0,%rax
jne    11fa <main+0x9a>
mov    0x2e0f(%rip),%rax
mov    (%rax),%edi
mov    -0x10(%rbp),%rax
mov    (%rax),%rdx
mov    -0x10(%rbp),%rax
mov    0x8(%rax),%rcx
lea    0xe33(%rip),%rsi
mov    $0x0,%al
call   1050 <fprintf@plt>
mov    $0x2,%edi
call   1080 <exit@plt>
mov    -0x8(%rbp),%eax
sub    $0x2,%eax
mov    %eax,-0x8(%rbp)
mov    -0x10(%rbp),%rax
add    $0x10,%rax
mov    %rax,-0x10(%rbp)
mov    -0x8(%rbp),%eax
mov    %eax,%ecx
add    $0xffffffff,%ecx
mov    %ecx,-0x8(%rbp)
cmp    $0x0,%eax
je     125d <main+0xfd>
mov    -0x10(%rbp),%rax
mov    %rax,%rcx
add    $0x8,%rcx
mov    %rcx,-0x10(%rbp)
mov    (%rax),%rdi
mov    -0x18(%rbp),%rsi
call   1040 <fputs@plt>
cmpl   $0x0,-0x8(%rbp)
je     1258 <main+0xf8>
mov    -0x18(%rbp),%rsi
lea    0xdec(%rip),%rdi
call   1040 <fputs@plt>
jmp    120f <main+0xaf>
mov    -0x18(%rbp),%rsi
lea    0xdb0(%rip),%rdi
call   1040 <fputs@plt>
mov    -0x18(%rbp),%rdi
call   1060 <fflush@plt>
mov    -0x18(%rbp),%rdi
call   1030 <fclose@plt>
xor    %eax,%eax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbp
push   %r15
push   %r14
push   %rbx
push   %rax
mov    %rsi,%r14
cmp    $0x2,%edi
jle    120c <main+0x9c>
mov    %edi,%ebp
mov    0x8(%r14),%rdi
lea    0xe8a(%rip),%rsi
call   1080 <fopen@plt>
test   %rax,%rax
je     1230 <main+0xc0>
mov    %rax,%rbx
mov    0x10(%r14),%rdi
mov    %rax,%rsi
call   1040 <fputs@plt>
cmp    $0x3,%ebp
je     11e2 <main+0x72>
mov    %ebp,%r15d
mov    $0x3,%ebp
nopw   0x0(%rax,%rax,1)
mov    $0x20,%edi
mov    %rbx,%rsi
call   1050 <fputc@plt>
mov    (%r14,%rbp,8),%rdi
mov    %rbx,%rsi
call   1040 <fputs@plt>
add    $0x1,%rbp
cmp    %ebp,%r15d
jne    11c0 <main+0x50>
mov    $0xa,%edi
mov    %rbx,%rsi
call   1050 <fputc@plt>
mov    %rbx,%rdi
call   1070 <fflush@plt>
mov    %rbx,%rdi
call   1030 <fclose@plt>
xor    %eax,%eax
add    $0x8,%rsp
pop    %rbx
pop    %r14
pop    %r15
pop    %rbp
ret
mov    0x2dcd(%rip),%rax
mov    (%rax),%edi
mov    (%r14),%rdx
lea    0xde1(%rip),%rsi
xor    %eax,%eax
call   1060 <fprintf@plt>
mov    $0x1,%edi
call   1090 <exit@plt>
mov    0x2da9(%rip),%rax
mov    (%rax),%edi
mov    (%r14),%rdx
mov    0x8(%r14),%rcx
lea    0xdd5(%rip),%rsi
xor    %eax,%eax
call   1060 <fprintf@plt>
mov    $0x2,%edi
call   1090 <exit@plt>

LLVM IR (-O0):
@stderr = global i32 0
@.str = [26 x i8] c"usage: %s file string...\0A\00"
@.str.1 = [2 x i8] c"w\00"
@.str.2 = [35 x i8] c"%s:could not open %s for writing.\0A\00"
@.str.3 = [2 x i8] c" \00"
@.str.4 = [2 x i8] c"\0A\00"
define i32 @main(i32 %0, i8** %1) {
%3 = alloca i32
%4 = alloca i32
%5 = alloca i8**
%6 = alloca i32*
store i32 0, i32* %3
store i32 %0, i32* %4
store i8** %1, i8*** %5
%7 = load i32, i32* %4
%8 = icmp slt i32 %7, 3
br i1 %8, label %9, label %16
9: ; preds = %2
%10 = load i32, i32* @stderr
%11 = load i8**, i8*** %5
%12 = getelementptr inbounds i8*, i8** %11, i64 0
%13 = load i8*, i8** %12
%14 = call i32 (i32, i8*, i8*, ...) @fprintf(i32 %10, i8* getelementptr inbounds ([26 x i8], [26 x i8]* @.str, i64 0, i64 0), i8* %13)
%15 = call i32 @exit(i32 1)
unreachable
16: ; preds = %2
%17 = load i8**, i8*** %5
%18 = getelementptr inbounds i8*, i8** %17, i64 1
%19 = load i8*, i8** %18
%20 = call i32* @fopen(i8* %19, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.1, i64 0, i64 0))
store i32* %20, i32** %6
%21 = icmp eq i32* %20, null
br i1 %21, label %22, label %32
22: ; preds = %16
%23 = load i32, i32* @stderr
%24 = load i8**, i8*** %5
%25 = getelementptr inbounds i8*, i8** %24, i64 0
%26 = load i8*, i8** %25
%27 = load i8**, i8*** %5
%28 = getelementptr inbounds i8*, i8** %27, i64 1
%29 = load i8*, i8** %28
%30 = call i32 (i32, i8*, i8*, ...) @fprintf(i32 %23, i8* getelementptr inbounds ([35 x i8], [35 x i8]* @.str.2, i64 0, i64 0), i8* %26, i8* %29)
%31 = call i32 @exit(i32 2)
unreachable
32: ; preds = %16
%33 = load i32, i32* %4
%34 = sub nsw i32 %33, 2
store i32 %34, i32* %4
%35 = load i8**, i8*** %5
%36 = getelementptr inbounds i8*, i8** %35, i64 2
store i8** %36, i8*** %5
br label %37
37: ; preds = %52, %32
%38 = load i32, i32* %4
%39 = add nsw i32 %38, -1
store i32 %39, i32* %4
%40 = icmp ne i32 %38, 0
br i1 %40, label %41, label %53
41: ; preds = %37
%42 = load i8**, i8*** %5
%43 = getelementptr inbounds i8*, i8** %42, i32 1
store i8** %43, i8*** %5
%44 = load i8*, i8** %42
%45 = load i32*, i32** %6
%46 = call i32 @fputs(i8* %44, i32* %45)
%47 = load i32, i32* %4
%48 = icmp ne i32 %47, 0
br i1 %48, label %49, label %52
49: ; preds = %41
%50 = load i32*, i32** %6
%51 = call i32 @fputs(i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.3, i64 0, i64 0), i32* %50)
br label %52
52: ; preds = %49, %41
br label %37
53: ; preds = %37
%54 = load i32*, i32** %6
%55 = call i32 @fputs(i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.4, i64 0, i64 0), i32* %54)
%56 = load i32*, i32** %6
%57 = call i32 @fflush(i32* %56)
%58 = load i32*, i32** %6
%59 = call i32 @fclose(i32* %58)
ret i32 0
}

LLVM IR (-O2):
@stderr = global i32 0
@.str = [26 x i8] c"usage: %s file string...\0A\00"
@.str.1 = [2 x i8] c"w\00"
@.str.2 = [35 x i8] c"%s:could not open %s for writing.\0A\00"
define i32 @main(i32 %0, i8** nocapture %1) {
%3 = icmp slt i32 %0, 3
br i1 %3, label %4, label %9
4: ; preds = %2
%5 = load i32, i32* @stderr
%6 = load i8*, i8** %1
%7 = tail call i32 (i32, i8*, i8*, ...) @fprintf(i32 %5, i8* getelementptr inbounds ([26 x i8], [26 x i8]* @.str, i64 0, i64 0), i8* %6)
%8 = tail call i32 @exit(i32 1)
unreachable
9: ; preds = %2
%10 = getelementptr inbounds i8*, i8** %1, i64 1
%11 = load i8*, i8** %10
%12 = tail call i32* @fopen(i8* %11, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.1, i64 0, i64 0))
%13 = icmp eq i32* %12, null
br i1 %13, label %14, label %20
14: ; preds = %9
%15 = load i32, i32* @stderr
%16 = load i8*, i8** %1
%17 = load i8*, i8** %10
%18 = tail call i32 (i32, i8*, i8*, ...) @fprintf(i32 %15, i8* getelementptr inbounds ([35 x i8], [35 x i8]* @.str.2, i64 0, i64 0), i8* %16, i8* %17)
%19 = tail call i32 @exit(i32 2)
unreachable
20: ; preds = %9
%21 = add nsw i32 %0, -3
%22 = getelementptr inbounds i8*, i8** %1, i64 2
%23 = load i8*, i8** %22
%24 = tail call i32 @fputs(i8* %23, i32* %12)
%25 = icmp eq i32 %21, 0
br i1 %25, label %35, label %26
26: ; preds = %20, %26
%27 = phi i8** [ %29, %26 ], [ %22, %20 ]
%28 = phi i32 [ %31, %26 ], [ %21, %20 ]
%29 = getelementptr inbounds i8*, i8** %27, i64 1
%30 = tail call i32 @fputc(i32 32, i32* %12)
%31 = add nsw i32 %28, -1
%32 = load i8*, i8** %29
%33 = tail call i32 @fputs(i8* %32, i32* %12)
%34 = icmp eq i32 %31, 0
br i1 %34, label %35, label %26
35: ; preds = %26, %20
%36 = tail call i32 @fputc(i32 10, i32* %12)
%37 = tail call i32 @fflush(i32* %12)
%38 = tail call i32 @fclose(i32* %12)
ret i32 0
}