#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);
scalar_t__ fclose(int /*<<< orphan*/ *);
int /*<<< orphan*/ *fopen(char *, char *);
int /*<<< orphan*/ fprintf(int /*<<< orphan*/, char *, char *);
int /*<<< orphan*/ perror(char *);
int /*<<< orphan*/ stderr;
int /*<<< orphan*/ write_body(int /*<<< orphan*/ *, char *, char *, char *);
int /*<<< orphan*/ write_header(int /*<<< orphan*/ *, char *, char *, char *);
int main(int argc, char *argv[]) {
  FILE *f;
  if (argc != 4) {
    fprintf(stderr, "%s version subversion platform\n", argv[0]);
    exit(1);
  }
  f = fopen("include/sysinfoblk.h", "w");
  if (f == NULL) {
    perror("include/sysinfoblk.h");
    exit(1);
  }
  write_header(f, argv[1], argv[2], argv[3]);
  fclose(f);
  f = fopen("version.c", "w");
  if (f == NULL) {
    perror("version.c");
    exit(1);
  }
  write_body(f, argv[1], argv[2], argv[3]);
  return fclose(f) != 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   $0x4,-0x8(%rbp)
je     11b6 <main+0x46>
mov    0x2e49(%rip),%rax
mov    (%rax),%edi
mov    -0x10(%rbp),%rax
mov    (%rax),%rdx
lea    0xe59(%rip),%rsi
call   1050 <fprintf@plt>
mov    $0x1,%edi
call   1080 <exit@plt>
lea    0xe63(%rip),%rdi
lea    0xe71(%rip),%rsi
call   1060 <fopen@plt>
mov    %rax,-0x18(%rbp)
cmpq   $0x0,-0x18(%rbp)
jne    11ee <main+0x7e>
lea    0xe41(%rip),%rdi
call   1070 <perror@plt>
mov    $0x1,%edi
call   1080 <exit@plt>
mov    -0x18(%rbp),%rdi
mov    -0x10(%rbp),%rax
mov    0x8(%rax),%rsi
mov    -0x10(%rbp),%rax
mov    0x10(%rax),%rdx
mov    -0x10(%rbp),%rax
mov    0x18(%rax),%rcx
call   1090 <write_header@plt>
mov    -0x18(%rbp),%rdi
call   1040 <fclose@plt>
lea    0xe18(%rip),%rdi
lea    0xe0f(%rip),%rsi
call   1060 <fopen@plt>
mov    %rax,-0x18(%rbp)
cmpq   $0x0,-0x18(%rbp)
jne    1250 <main+0xe0>
lea    0xdf6(%rip),%rdi
call   1070 <perror@plt>
mov    $0x1,%edi
call   1080 <exit@plt>
mov    -0x18(%rbp),%rdi
mov    -0x10(%rbp),%rax
mov    0x8(%rax),%rsi
mov    -0x10(%rbp),%rax
mov    0x10(%rax),%rdx
mov    -0x10(%rbp),%rax
mov    0x18(%rax),%rcx
call   1030 <write_body@plt>
mov    -0x18(%rbp),%rdi
call   1040 <fclose@plt>
cmp    $0x0,%rax
setne  %al
and    $0x1,%al
movzbl %al,%eax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %r14
push   %rbx
push   %rax
mov    %rsi,%r14
cmp    $0x4,%edi
jne    1204 <main+0x94>
lea    0xe99(%rip),%rdi
lea    0xea7(%rip),%rsi
call   1060 <fopen@plt>
test   %rax,%rax
je     1226 <main+0xb6>
mov    %rax,%rbx
mov    0x8(%r14),%rsi
mov    0x10(%r14),%rdx
mov    0x18(%r14),%rcx
mov    %rax,%rdi
call   1090 <write_header@plt>
mov    %rbx,%rdi
call   1040 <fclose@plt>
lea    0xe75(%rip),%rdi
lea    0xe6c(%rip),%rsi
call   1060 <fopen@plt>
test   %rax,%rax
je     122f <main+0xbf>
mov    %rax,%rbx
mov    0x8(%r14),%rsi
mov    0x10(%r14),%rdx
mov    0x18(%r14),%rcx
mov    %rax,%rdi
call   1030 <write_body@plt>
mov    %rbx,%rdi
call   1040 <fclose@plt>
xor    %ecx,%ecx
test   %rax,%rax
setne  %cl
mov    %ecx,%eax
add    $0x8,%rsp
pop    %rbx
pop    %r14
ret
mov    0x2dd5(%rip),%rax
mov    (%rax),%edi
mov    (%r14),%rdx
lea    0xde9(%rip),%rsi
call   1050 <fprintf@plt>
mov    $0x1,%edi
call   1080 <exit@plt>
lea    0xdf3(%rip),%rdi
jmp    1236 <main+0xc6>
lea    0xe01(%rip),%rdi
call   1070 <perror@plt>
mov    $0x1,%edi
call   1080 <exit@plt>

LLVM IR (-O0):
@stderr = global i32 0
@.str = [32 x i8] c"%s version subversion platform\0A\00"
@.str.1 = [21 x i8] c"include/sysinfoblk.h\00"
@.str.2 = [2 x i8] c"w\00"
@.str.3 = [10 x i8] c"version.c\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 ne i32 %7, 4
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 @fprintf(i32 %10, i8* getelementptr inbounds ([32 x i8], [32 x i8]* @.str, i64 0, i64 0), i8* %13)
%15 = call i32 @exit(i32 1)
unreachable
16: ; preds = %2
%17 = call i32* @fopen(i8* getelementptr inbounds ([21 x i8], [21 x i8]* @.str.1, i64 0, i64 0), i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.2, i64 0, i64 0))
store i32* %17, i32** %6
%18 = load i32*, i32** %6
%19 = icmp eq i32* %18, null
br i1 %19, label %20, label %23
20: ; preds = %16
%21 = call i32 @perror(i8* getelementptr inbounds ([21 x i8], [21 x i8]* @.str.1, i64 0, i64 0))
%22 = call i32 @exit(i32 1)
unreachable
23: ; preds = %16
%24 = load i32*, i32** %6
%25 = load i8**, i8*** %5
%26 = getelementptr inbounds i8*, i8** %25, i64 1
%27 = load i8*, i8** %26
%28 = load i8**, i8*** %5
%29 = getelementptr inbounds i8*, i8** %28, i64 2
%30 = load i8*, i8** %29
%31 = load i8**, i8*** %5
%32 = getelementptr inbounds i8*, i8** %31, i64 3
%33 = load i8*, i8** %32
%34 = call i32 @write_header(i32* %24, i8* %27, i8* %30, i8* %33)
%35 = load i32*, i32** %6
%36 = call i64 @fclose(i32* %35)
%37 = call i32* @fopen(i8* getelementptr inbounds ([10 x i8], [10 x i8]* @.str.3, i64 0, i64 0), i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.2, i64 0, i64 0))
store i32* %37, i32** %6
%38 = load i32*, i32** %6
%39 = icmp eq i32* %38, null
br i1 %39, label %40, label %43
40: ; preds = %23
%41 = call i32 @perror(i8* getelementptr inbounds ([10 x i8], [10 x i8]* @.str.3, i64 0, i64 0))
%42 = call i32 @exit(i32 1)
unreachable
43: ; preds = %23
%44 = load i32*, i32** %6
%45 = load i8**, i8*** %5
%46 = getelementptr inbounds i8*, i8** %45, i64 1
%47 = load i8*, i8** %46
%48 = load i8**, i8*** %5
%49 = getelementptr inbounds i8*, i8** %48, i64 2
%50 = load i8*, i8** %49
%51 = load i8**, i8*** %5
%52 = getelementptr inbounds i8*, i8** %51, i64 3
%53 = load i8*, i8** %52
%54 = call i32 @write_body(i32* %44, i8* %47, i8* %50, i8* %53)
%55 = load i32*, i32** %6
%56 = call i64 @fclose(i32* %55)
%57 = icmp ne i64 %56, 0
%58 = zext i1 %57 to i32
ret i32 %58
}

LLVM IR (-O2):
@stderr = global i32 0
@.str = [32 x i8] c"%s version subversion platform\0A\00"
@.str.1 = [21 x i8] c"include/sysinfoblk.h\00"
@.str.2 = [2 x i8] c"w\00"
@.str.3 = [10 x i8] c"version.c\00"
define i32 @main(i32 %0, i8** nocapture %1) {
%3 = icmp eq i32 %0, 4
br i1 %3, label %9, label %4
4: ; preds = %2
%5 = load i32, i32* @stderr
%6 = load i8*, i8** %1
%7 = tail call i32 @fprintf(i32 %5, i8* getelementptr inbounds ([32 x i8], [32 x i8]* @.str, i64 0, i64 0), i8* %6)
%8 = tail call i32 @exit(i32 1)
unreachable
9: ; preds = %2
%10 = tail call i32* @fopen(i8* getelementptr inbounds ([21 x i8], [21 x i8]* @.str.1, i64 0, i64 0), i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.2, i64 0, i64 0))
%11 = icmp eq i32* %10, null
br i1 %11, label %12, label %15
12: ; preds = %9
%13 = tail call i32 @perror(i8* getelementptr inbounds ([21 x i8], [21 x i8]* @.str.1, i64 0, i64 0))
%14 = tail call i32 @exit(i32 1)
unreachable
15: ; preds = %9
%16 = getelementptr inbounds i8*, i8** %1, i64 1
%17 = load i8*, i8** %16
%18 = getelementptr inbounds i8*, i8** %1, i64 2
%19 = load i8*, i8** %18
%20 = getelementptr inbounds i8*, i8** %1, i64 3
%21 = load i8*, i8** %20
%22 = tail call i32 @write_header(i32* %10, i8* %17, i8* %19, i8* %21)
%23 = tail call i64 @fclose(i32* %10)
%24 = tail call i32* @fopen(i8* getelementptr inbounds ([10 x i8], [10 x i8]* @.str.3, i64 0, i64 0), i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.2, i64 0, i64 0))
%25 = icmp eq i32* %24, null
br i1 %25, label %26, label %29
26: ; preds = %15
%27 = tail call i32 @perror(i8* getelementptr inbounds ([10 x i8], [10 x i8]* @.str.3, i64 0, i64 0))
%28 = tail call i32 @exit(i32 1)
unreachable
29: ; preds = %15
%30 = load i8*, i8** %16
%31 = load i8*, i8** %18
%32 = load i8*, i8** %20
%33 = tail call i32 @write_body(i32* %24, i8* %30, i8* %31, i8* %32)
%34 = tail call i64 @fclose(i32* %24)
%35 = icmp ne i64 %34, 0
%36 = zext i1 %35 to i32
ret i32 %36
}