#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*/ *);
int /*<<< orphan*/ fprintf(int /*<<< orphan*/ *, char *, ...);
int /*<<< orphan*/ free(char *);
size_t getline(char **, size_t *, int /*<<< orphan*/ *);
scalar_t__ malloc(int);
int /*<<< orphan*/ *open_header(char *);
int /*<<< orphan*/ *open_master();
int copy(char *arch) {
  FILE *header = open_header(arch);
  FILE *master = open_master();
  char *buffer = (char *)malloc(512 * sizeof(char));
  size_t bsize = 512;
  size_t ret = 0;
  fprintf(master, "// This file was generated automatically by autoconf.c\n");
  fprintf(master, "// You should not modify it unless you really know what "
                  "you're doing.\n");
  while ((ret = getline(&buffer, &bsize, header)) != -1) {
    fprintf(master, "%s", buffer);
  }
  if (header) {
    fclose(header);
  }
  if (master) {
    fclose(master);
  }
  if (buffer) {
    free(buffer);
  }
  return 0;
}


x86 assembly (clang, -O0):
<copy>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
mov    %rdi,-0x8(%rbp)
mov    -0x8(%rbp),%rdi
call   1040 <open_header@plt>
mov    %rax,-0x10(%rbp)
mov    $0x0,%al
call   1060 <open_master@plt>
mov    %rax,-0x18(%rbp)
mov    $0x200,%edi
call   1080 <malloc@plt>
mov    %rax,-0x20(%rbp)
movq   $0x200,-0x28(%rbp)
movq   $0x0,-0x30(%rbp)
mov    -0x18(%rbp),%rdi
lea    0xe43(%rip),%rsi
mov    $0x0,%al
call   1070 <fprintf@plt>
mov    -0x18(%rbp),%rdi
lea    0xe69(%rip),%rsi
mov    $0x0,%al
call   1070 <fprintf@plt>
mov    -0x10(%rbp),%rdx
lea    -0x20(%rbp),%rdi
lea    -0x28(%rbp),%rsi
call   1090 <getline@plt>
mov    %rax,-0x30(%rbp)
cmp    $0xffffffffffffffff,%rax
je     1210 <copy+0xa0>
mov    -0x18(%rbp),%rdi
mov    -0x20(%rbp),%rdx
lea    0xe7b(%rip),%rsi
mov    $0x0,%al
call   1070 <fprintf@plt>
jmp    11d6 <copy+0x66>
cmpq   $0x0,-0x10(%rbp)
je     1224 <copy+0xb4>
mov    -0x10(%rbp),%rdi
call   1050 <fclose@plt>
cmpq   $0x0,-0x18(%rbp)
je     1238 <copy+0xc8>
mov    -0x18(%rbp),%rdi
call   1050 <fclose@plt>
cmpq   $0x0,-0x20(%rbp)
je     124c <copy+0xdc>
mov    -0x20(%rbp),%rdi
call   1030 <free@plt>
xor    %eax,%eax
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<copy>:
push   %r15
push   %r14
push   %r12
push   %rbx
sub    $0x18,%rsp
call   1040 <open_header@plt>
mov    %rax,%r14
xor    %eax,%eax
call   1070 <open_master@plt>
mov    %rax,%rbx
mov    $0x200,%edi
call   1080 <malloc@plt>
mov    %rax,0x8(%rsp)
movq   $0x200,0x10(%rsp)
lea    0xe44(%rip),%rdi
mov    $0x37,%esi
mov    $0x1,%edx
mov    %rbx,%rcx
call   10a0 <fwrite@plt>
lea    0xe63(%rip),%rdi
mov    $0x46,%esi
mov    $0x1,%edx
mov    %rbx,%rcx
call   10a0 <fwrite@plt>
lea    0x8(%rsp),%rdi
lea    0x10(%rsp),%rsi
mov    %r14,%rdx
call   1090 <getline@plt>
cmp    $0xffffffffffffffff,%rax
je     1231 <copy+0xb1>
lea    0x8(%rsp),%r15
lea    0x10(%rsp),%r12
nopl   0x0(%rax)
mov    0x8(%rsp),%rdi
mov    %rbx,%rsi
call   1060 <fputs@plt>
mov    %r15,%rdi
mov    %r12,%rsi
mov    %r14,%rdx
call   1090 <getline@plt>
cmp    $0xffffffffffffffff,%rax
jne    1210 <copy+0x90>
test   %r14,%r14
je     123e <copy+0xbe>
mov    %r14,%rdi
call   1050 <fclose@plt>
test   %rbx,%rbx
je     124b <copy+0xcb>
mov    %rbx,%rdi
call   1050 <fclose@plt>
mov    0x8(%rsp),%rdi
test   %rdi,%rdi
je     125a <copy+0xda>
call   1030 <free@plt>
xor    %eax,%eax
add    $0x18,%rsp
pop    %rbx
pop    %r12
pop    %r14
pop    %r15
ret

LLVM IR (-O0):
@.str = [56 x i8] c"// This file was generated automatically by autoconf.c\0A\00"
@.str.1 = [71 x i8] c"// You should not modify it unless you really know what you're doing.\0A\00"
@.str.2 = [3 x i8] c"%s\00"
define i32 @copy(i8* %0) {
%2 = alloca i8*
%3 = alloca i32*
%4 = alloca i32*
%5 = alloca i8*
%6 = alloca i64
%7 = alloca i64
store i8* %0, i8** %2
%8 = load i8*, i8** %2
%9 = call i32* @open_header(i8* %8)
store i32* %9, i32** %3
%10 = call i32* (...) @open_master()
store i32* %10, i32** %4
%11 = call i64 @malloc(i32 512)
%12 = inttoptr i64 %11 to i8*
store i8* %12, i8** %5
store i64 512, i64* %6
store i64 0, i64* %7
%13 = load i32*, i32** %4
%14 = call i32 (i32*, i8*, ...) @fprintf(i32* %13, i8* getelementptr inbounds ([56 x i8], [56 x i8]* @.str, i64 0, i64 0))
%15 = load i32*, i32** %4
%16 = call i32 (i32*, i8*, ...) @fprintf(i32* %15, i8* getelementptr inbounds ([71 x i8], [71 x i8]* @.str.1, i64 0, i64 0))
br label %17
17: ; preds = %21, %1
%18 = load i32*, i32** %3
%19 = call i64 @getline(i8** %5, i64* %6, i32* %18)
store i64 %19, i64* %7
%20 = icmp ne i64 %19, -1
br i1 %20, label %21, label %25
21: ; preds = %17
%22 = load i32*, i32** %4
%23 = load i8*, i8** %5
%24 = call i32 (i32*, i8*, ...) @fprintf(i32* %22, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.2, i64 0, i64 0), i8* %23)
br label %17
25: ; preds = %17
%26 = load i32*, i32** %3
%27 = icmp ne i32* %26, null
br i1 %27, label %28, label %31
28: ; preds = %25
%29 = load i32*, i32** %3
%30 = call i32 @fclose(i32* %29)
br label %31
31: ; preds = %28, %25
%32 = load i32*, i32** %4
%33 = icmp ne i32* %32, null
br i1 %33, label %34, label %37
34: ; preds = %31
%35 = load i32*, i32** %4
%36 = call i32 @fclose(i32* %35)
br label %37
37: ; preds = %34, %31
%38 = load i8*, i8** %5
%39 = icmp ne i8* %38, null
br i1 %39, label %40, label %43
40: ; preds = %37
%41 = load i8*, i8** %5
%42 = call i32 @free(i8* %41)
br label %43
43: ; preds = %40, %37
ret i32 0
}

LLVM IR (-O2):
@.str = [56 x i8] c"// This file was generated automatically by autoconf.c\0A\00"
@.str.1 = [71 x i8] c"// You should not modify it unless you really know what you're doing.\0A\00"
define i32 @copy(i8* %0) {
%2 = alloca i8*
%3 = alloca i64
%4 = tail call i32* @open_header(i8* %0)
%5 = tail call i32* (...) @open_master()
%6 = bitcast i8** %2 to i8*
%7 = tail call i64 @malloc(i32 512)
%8 = inttoptr i64 %7 to i8*
store i8* %8, i8** %2
%9 = bitcast i64* %3 to i8*
store i64 512, i64* %3
%10 = tail call i64 @fwrite(i8* getelementptr inbounds ([56 x i8], [56 x i8]* @.str, i64 0, i64 0), i64 55, i64 1, i32* %5)
%11 = tail call i64 @fwrite(i8* getelementptr inbounds ([71 x i8], [71 x i8]* @.str.1, i64 0, i64 0), i64 70, i64 1, i32* %5)
%12 = call i64 @getline(i8** %2, i64* %3, i32* %4)
%13 = icmp eq i64 %12, -1
br i1 %13, label %19, label %14
14: ; preds = %1, %14
%15 = load i8*, i8** %2
%16 = call i32 @fputs(i8* %15, i32* %5)
%17 = call i64 @getline(i8** %2, i64* %3, i32* %4)
%18 = icmp eq i64 %17, -1
br i1 %18, label %19, label %14
19: ; preds = %14, %1
%20 = icmp eq i32* %4, null
br i1 %20, label %23, label %21
21: ; preds = %19
%22 = call i32 @fclose(i32* %4)
br label %23
23: ; preds = %21, %19
%24 = icmp eq i32* %5, null
br i1 %24, label %27, label %25
25: ; preds = %23
%26 = call i32 @fclose(i32* %5)
br label %27
27: ; preds = %25, %23
%28 = load i8*, i8** %2
%29 = icmp eq i8* %28, null
br i1 %29, label %32, label %30
30: ; preds = %27
%31 = call i32 @free(i8* %28)
br label %32
32: ; preds = %30, %27
ret i32 0
}