#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*/ fclose(int /*<<< orphan*/ *);
scalar_t__ fgets(char *, int, int /*<<< orphan*/ *);
int /*<<< orphan*/ *fopen(char *, char *);
int /*<<< orphan*/ fprintf(int /*<<< orphan*/ *, char *, char *);
int /*<<< orphan*/ mk_iatom(char *, int /*<<< orphan*/ *);
int /*<<< orphan*/ printf(char *);
int /*<<< orphan*/ rewind(int /*<<< orphan*/ *);
int /*<<< orphan*/ strcpy(char *, char *);
int /*<<< orphan*/ *tmpfile();
int main(int argc, char *argv[]) {
  FILE *fpOut;
  FILE *temp_fp;
  char new_name[256] = "";
  char line[256];
  strcpy(new_name, argv[2]);
  temp_fp = tmpfile();
  if (argc < 3) {
    printf("mk_iatom param_file out_file\n");
    return 0;
  }
  mk_iatom(argv[1], temp_fp);
  rewind(temp_fp);
  fpOut = fopen(new_name, "w");
  while (fgets(line, 256, temp_fp))
    fprintf(fpOut, "%s", line);
  fclose(temp_fp);
  fclose(fpOut);
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x220,%rsp
movl   $0x0,-0x4(%rbp)
mov    %edi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
lea    -0x120(%rbp),%rdi
xor    %esi,%esi
mov    $0x100,%edx
call   1070 <memset@plt>
lea    -0x120(%rbp),%rdi
mov    -0x10(%rbp),%rax
mov    0x10(%rax),%rsi
call   1030 <strcpy@plt>
mov    $0x0,%al
call   1090 <tmpfile@plt>
mov    %rax,-0x20(%rbp)
cmpl   $0x3,-0x8(%rbp)
jge    120d <main+0x6d>
lea    0xe04(%rip),%rdi
call   1050 <printf@plt>
movl   $0x0,-0x4(%rbp)
jmp    1292 <main+0xf2>
mov    -0x10(%rbp),%rax
mov    0x8(%rax),%rdi
mov    -0x20(%rbp),%rsi
call   10c0 <mk_iatom@plt>
mov    -0x20(%rbp),%rdi
call   1060 <rewind@plt>
lea    -0x120(%rbp),%rdi
lea    0xde9(%rip),%rsi
call   10b0 <fopen@plt>
mov    %rax,-0x18(%rbp)
lea    -0x220(%rbp),%rdi
mov    -0x20(%rbp),%rdx
mov    $0x100,%esi
call   1080 <fgets@plt>
cmp    $0x0,%rax
je     1279 <main+0xd9>
mov    -0x18(%rbp),%rdi
lea    -0x220(%rbp),%rdx
lea    0xdb1(%rip),%rsi
call   10a0 <fprintf@plt>
jmp    123e <main+0x9e>
mov    -0x20(%rbp),%rdi
call   1040 <fclose@plt>
mov    -0x18(%rbp),%rdi
call   1040 <fclose@plt>
movl   $0x0,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x220,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbp
push   %r14
push   %rbx
sub    $0x200,%rsp
mov    %rsi,%rbx
mov    %edi,%ebp
xorps  %xmm0,%xmm0
movaps %xmm0,0xf0(%rsp)
movaps %xmm0,0xe0(%rsp)
movaps %xmm0,0xd0(%rsp)
movaps %xmm0,0xc0(%rsp)
movaps %xmm0,0xb0(%rsp)
movaps %xmm0,0xa0(%rsp)
movaps %xmm0,0x90(%rsp)
movaps %xmm0,0x80(%rsp)
movaps %xmm0,0x70(%rsp)
movaps %xmm0,0x60(%rsp)
movaps %xmm0,0x50(%rsp)
movaps %xmm0,0x40(%rsp)
movaps %xmm0,0x30(%rsp)
movaps %xmm0,0x20(%rsp)
movaps %xmm0,0x10(%rsp)
movaps %xmm0,(%rsp)
mov    0x10(%rsi),%rsi
mov    %rsp,%rdi
call   1030 <strcpy@plt>
xor    %eax,%eax
call   1090 <tmpfile@plt>
cmp    $0x2,%ebp
jg     1233 <main+0xa3>
lea    0xdd9(%rip),%rdi
call   1040 <puts@plt>
jmp    12b0 <main+0x120>
mov    %rax,%r14
mov    0x8(%rbx),%rdi
mov    %rax,%rsi
call   10b0 <mk_iatom@plt>
mov    %r14,%rdi
call   1060 <rewind@plt>
lea    0xdaf(%rip),%rsi
mov    %rsp,%rdi
call   10a0 <fopen@plt>
mov    %rax,%rbx
lea    0x100(%rsp),%rdi
mov    $0x100,%esi
mov    %r14,%rdx
call   1080 <fgets@plt>
test   %rax,%rax
je     12a0 <main+0x110>
lea    0x100(%rsp),%rbp
xchg   %ax,%ax
mov    %rbp,%rdi
mov    %rbx,%rsi
call   1070 <fputs@plt>
mov    %rbp,%rdi
mov    $0x100,%esi
mov    %r14,%rdx
call   1080 <fgets@plt>
test   %rax,%rax
jne    1280 <main+0xf0>
mov    %r14,%rdi
call   1050 <fclose@plt>
mov    %rbx,%rdi
call   1050 <fclose@plt>
xor    %eax,%eax
add    $0x200,%rsp
pop    %rbx
pop    %r14
pop    %rbp
ret

LLVM IR (-O0):
@.str = [30 x i8] c"mk_iatom param_file out_file\0A\00"
@.str.1 = [2 x i8] c"w\00"
@.str.2 = [3 x i8] c"%s\00"
define i32 @main(i32 %0, i8** %1) {
%3 = alloca i32
%4 = alloca i32
%5 = alloca i8**
%6 = alloca i32*
%7 = alloca i32*
%8 = alloca [256 x i8]
%9 = alloca [256 x i8]
store i32 0, i32* %3
store i32 %0, i32* %4
store i8** %1, i8*** %5
%10 = bitcast [256 x i8]* %8 to i8*
%11 = getelementptr inbounds [256 x i8], [256 x i8]* %8, i64 0, i64 0
%12 = load i8**, i8*** %5
%13 = getelementptr inbounds i8*, i8** %12, i64 2
%14 = load i8*, i8** %13
%15 = call i32 @strcpy(i8* %11, i8* %14)
%16 = call i32* (...) @tmpfile()
store i32* %16, i32** %7
%17 = load i32, i32* %4
%18 = icmp slt i32 %17, 3
br i1 %18, label %19, label %21
19: ; preds = %2
%20 = call i32 @printf(i8* getelementptr inbounds ([30 x i8], [30 x i8]* @.str, i64 0, i64 0))
store i32 0, i32* %3
br label %45
21: ; preds = %2
%22 = load i8**, i8*** %5
%23 = getelementptr inbounds i8*, i8** %22, i64 1
%24 = load i8*, i8** %23
%25 = load i32*, i32** %7
%26 = call i32 @mk_iatom(i8* %24, i32* %25)
%27 = load i32*, i32** %7
%28 = call i32 @rewind(i32* %27)
%29 = getelementptr inbounds [256 x i8], [256 x i8]* %8, i64 0, i64 0
%30 = call i32* @fopen(i8* %29, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.1, i64 0, i64 0))
store i32* %30, i32** %6
br label %31
31: ; preds = %36, %21
%32 = getelementptr inbounds [256 x i8], [256 x i8]* %9, i64 0, i64 0
%33 = load i32*, i32** %7
%34 = call i64 @fgets(i8* %32, i32 256, i32* %33)
%35 = icmp ne i64 %34, 0
br i1 %35, label %36, label %40
36: ; preds = %31
%37 = load i32*, i32** %6
%38 = getelementptr inbounds [256 x i8], [256 x i8]* %9, i64 0, i64 0
%39 = call i32 @fprintf(i32* %37, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.2, i64 0, i64 0), i8* %38)
br label %31
40: ; preds = %31
%41 = load i32*, i32** %7
%42 = call i32 @fclose(i32* %41)
%43 = load i32*, i32** %6
%44 = call i32 @fclose(i32* %43)
store i32 0, i32* %3
br label %45
45: ; preds = %40, %19
%46 = load i32, i32* %3
ret i32 %46
}

LLVM IR (-O2):
@.str.1 = [2 x i8] c"w\00"
@str = [29 x i8] c"mk_iatom param_file out_file\00"
define i32 @main(i32 %0, i8** nocapture %1) {
%3 = alloca [256 x i8]
%4 = alloca [256 x i8]
%5 = getelementptr inbounds [256 x i8], [256 x i8]* %3, i64 0, i64 0
%6 = getelementptr inbounds [256 x i8], [256 x i8]* %4, i64 0, i64 0
%7 = getelementptr inbounds i8*, i8** %1, i64 2
%8 = load i8*, i8** %7
%9 = call i32 @strcpy(i8* %5, i8* %8)
%10 = call i32* (...) @tmpfile()
%11 = icmp slt i32 %0, 3
br i1 %11, label %12, label %14
12: ; preds = %2
%13 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([29 x i8], [29 x i8]* @str, i64 0, i64 0))
br label %29
14: ; preds = %2
%15 = getelementptr inbounds i8*, i8** %1, i64 1
%16 = load i8*, i8** %15
%17 = call i32 @mk_iatom(i8* %16, i32* %10)
%18 = call i32 @rewind(i32* %10)
%19 = call i32* @fopen(i8* %5, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.1, i64 0, i64 0))
%20 = call i64 @fgets(i8* %6, i32 256, i32* %10)
%21 = icmp eq i64 %20, 0
br i1 %21, label %26, label %22
22: ; preds = %14, %22
%23 = call i32 @fputs(i8* %6, i32* %19)
%24 = call i64 @fgets(i8* %6, i32 256, i32* %10)
%25 = icmp eq i64 %24, 0
br i1 %25, label %26, label %22
26: ; preds = %22, %14
%27 = call i32 @fclose(i32* %10)
%28 = call i32 @fclose(i32* %19)
br label %29
29: ; preds = %26, %12
ret i32 0
}