#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 ssize_t;
typedef int /*<<< orphan*/ FILE;

/* Variables and functions */
int /*<<< orphan*/ EXIT_FAILURE;
int /*<<< orphan*/ EXIT_SUCCESS;
int /*<<< orphan*/ clearerr(int /*<<< orphan*/ *);
int /*<<< orphan*/ err_exit(char *, ...);
int /*<<< orphan*/ err_log(char *, int /*<<< orphan*/);
int /*<<< orphan*/ errno;
int /*<<< orphan*/ exit(int /*<<< orphan*/);
int /*<<< orphan*/ fclose(int /*<<< orphan*/ *);
scalar_t__ ferror(int /*<<< orphan*/ *);
int /*<<< orphan*/ *fopen(char *, char *);
int /*<<< orphan*/ free(char *);
int fwrite(char *, int, int, int /*<<< orphan*/ *);
int getline(char **, size_t *, int /*<<< orphan*/ *);
scalar_t__ malloc(int);
int /*<<< orphan*/ strerror(int /*<<< orphan*/);
int /*<<< orphan*/ usage();
int main(int argc, char **argv) {
  char *input_file_path, *output_file_path;
  FILE *input_file, *output_file;
  ssize_t nread;
  char *buf;
  size_t buf_size;
  if (argc != 3) {
    usage();
    exit(EXIT_FAILURE);
  }
  input_file_path = argv[1];
  output_file_path = argv[2];
  buf_size = 128;
  buf = (char *)malloc(sizeof(char) * buf_size);
  if (buf == NULL) {
    err_exit("malloc error\n");
  }
  input_file = fopen(input_file_path, "r");
  if (input_file == NULL) {
    err_exit("fopen %s error: %s\n", input_file_path, strerror(errno));
  }
  output_file = fopen(output_file_path, "w");
  if (output_file == NULL) {
    err_exit("fopen %s error: %s\n", output_file_path, strerror(errno));
  }
  clearerr(input_file);
  while ((nread = getline(&buf, &buf_size, input_file)) != -1) {
    if (fwrite(buf, 1, nread, output_file) != nread) {
      err_exit("fwrite error\n");
    }
  }
  if (ferror(input_file) != 0) {
    err_log("getline error: %s\n", strerror(errno));
  }
  free(buf);
  fclose(input_file);
  fclose(output_file);
  exit(EXIT_SUCCESS);
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x60,%rsp
movl   $0x0,-0x4(%rbp)
mov    %edi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
cmpl   $0x3,-0x8(%rbp)
je     1205 <main+0x35>
mov    $0x0,%al
call   10a0 <usage@plt>
mov    0x2dda(%rip),%rax
mov    (%rax),%edi
call   10d0 <exit@plt>
mov    -0x10(%rbp),%rax
mov    0x8(%rax),%rax
mov    %rax,-0x18(%rbp)
mov    -0x10(%rbp),%rax
mov    0x10(%rax),%rax
mov    %rax,-0x20(%rbp)
movq   $0x80,-0x48(%rbp)
mov    -0x48(%rbp),%rax
shl    $0x0,%rax
mov    %eax,%edi
call   1080 <malloc@plt>
mov    %rax,-0x40(%rbp)
cmpq   $0x0,-0x40(%rbp)
jne    1251 <main+0x81>
lea    0xdb6(%rip),%rdi
mov    $0x0,%al
call   1090 <err_exit@plt>
mov    -0x18(%rbp),%rdi
lea    0xdb2(%rip),%rsi
call   10b0 <fopen@plt>
mov    %rax,-0x28(%rbp)
cmpq   $0x0,-0x28(%rbp)
jne    129a <main+0xca>
mov    -0x18(%rbp),%rax
mov    %rax,-0x50(%rbp)
mov    0x2d61(%rip),%rax
mov    (%rax),%edi
call   10f0 <strerror@plt>
mov    -0x50(%rbp),%rsi
mov    %eax,%edx
lea    0xd7d(%rip),%rdi
mov    $0x0,%al
call   1090 <err_exit@plt>
mov    -0x20(%rbp),%rdi
lea    0xd7f(%rip),%rsi
call   10b0 <fopen@plt>
mov    %rax,-0x30(%rbp)
cmpq   $0x0,-0x30(%rbp)
jne    12e3 <main+0x113>
mov    -0x20(%rbp),%rax
mov    %rax,-0x58(%rbp)
mov    0x2d18(%rip),%rax
mov    (%rax),%edi
call   10f0 <strerror@plt>
mov    -0x58(%rbp),%rsi
mov    %eax,%edx
lea    0xd34(%rip),%rdi
mov    $0x0,%al
call   1090 <err_exit@plt>
mov    -0x28(%rbp),%rdi
call   1070 <clearerr@plt>
mov    -0x28(%rbp),%rdx
lea    -0x40(%rbp),%rdi
lea    -0x48(%rbp),%rsi
call   10c0 <getline@plt>
mov    %eax,-0x34(%rbp)
cmp    $0xffffffff,%eax
je     133a <main+0x16a>
mov    -0x40(%rbp),%rdi
mov    -0x34(%rbp),%edx
mov    -0x30(%rbp),%rcx
mov    $0x1,%esi
call   10e0 <fwrite@plt>
cmp    -0x34(%rbp),%eax
je     1335 <main+0x165>
lea    0xcf8(%rip),%rdi
mov    $0x0,%al
call   1090 <err_exit@plt>
jmp    12ec <main+0x11c>
mov    -0x28(%rbp),%rdi
call   1040 <ferror@plt>
cmp    $0x0,%rax
je     1369 <main+0x199>
mov    0x2c8c(%rip),%rax
mov    (%rax),%edi
call   10f0 <strerror@plt>
mov    %eax,%esi
lea    0xcd0(%rip),%rdi
call   1060 <err_log@plt>
mov    -0x40(%rbp),%rdi
call   1030 <free@plt>
mov    -0x28(%rbp),%rdi
call   1050 <fclose@plt>
mov    -0x30(%rbp),%rdi
call   1050 <fclose@plt>
mov    0x2c45(%rip),%rax
mov    (%rax),%edi
call   10d0 <exit@plt>

x86 assembly (clang, -O2):
<main>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
sub    $0x18,%rsp
cmp    $0x3,%edi
jne    12fa <main+0x12a>
mov    0x8(%rsi),%rbx
mov    0x10(%rsi),%r15
movq   $0x80,0x10(%rsp)
mov    $0x80,%edi
call   1080 <malloc@plt>
mov    %rax,0x8(%rsp)
test   %rax,%rax
jne    121a <main+0x4a>
lea    0xded(%rip),%rdi
xor    %eax,%eax
call   1090 <err_exit@plt>
lea    0xded(%rip),%rsi
mov    %rbx,%rdi
call   10b0 <fopen@plt>
mov    %rax,%r14
test   %rax,%rax
jne    1252 <main+0x82>
mov    0x2da8(%rip),%rax
mov    (%rax),%edi
call   10f0 <strerror@plt>
lea    0xdca(%rip),%rdi
mov    %rbx,%rsi
mov    %eax,%edx
xor    %eax,%eax
call   1090 <err_exit@plt>
lea    0xdcb(%rip),%rsi
mov    %r15,%rdi
call   10b0 <fopen@plt>
mov    %rax,%r12
test   %rax,%rax
jne    128a <main+0xba>
mov    0x2d70(%rip),%rax
mov    (%rax),%edi
call   10f0 <strerror@plt>
lea    0xd92(%rip),%rdi
mov    %r15,%rsi
mov    %eax,%edx
xor    %eax,%eax
call   1090 <err_exit@plt>
mov    %r14,%rdi
call   1070 <clearerr@plt>
lea    0x8(%rsp),%rdi
lea    0x10(%rsp),%rsi
mov    %r14,%rdx
call   10c0 <getline@plt>
cmp    $0xffffffff,%eax
jne    130f <main+0x13f>
mov    %r14,%rdi
call   1040 <ferror@plt>
test   %rax,%rax
je     12d2 <main+0x102>
mov    0x2d23(%rip),%rax
mov    (%rax),%edi
call   10f0 <strerror@plt>
lea    0xd69(%rip),%rdi
mov    %eax,%esi
call   1060 <err_log@plt>
mov    0x8(%rsp),%rdi
call   1030 <free@plt>
mov    %r14,%rdi
call   1050 <fclose@plt>
mov    %r12,%rdi
call   1050 <fclose@plt>
mov    0x2cdd(%rip),%rax
mov    (%rax),%edi
call   10d0 <exit@plt>
xor    %eax,%eax
call   10a0 <usage@plt>
mov    0x2cd0(%rip),%rax
mov    (%rax),%edi
call   10d0 <exit@plt>
mov    %eax,%ebp
lea    0x8(%rsp),%r15
lea    0x10(%rsp),%rbx
lea    0xd04(%rip),%r13
jmp    1349 <main+0x179>
cs nopw 0x0(%rax,%rax,1)
xchg   %ax,%ax
mov    %r15,%rdi
mov    %rbx,%rsi
mov    %r14,%rdx
call   10c0 <getline@plt>
mov    %eax,%ebp
cmp    $0xffffffff,%eax
je     12a9 <main+0xd9>
mov    0x8(%rsp),%rdi
mov    $0x1,%esi
mov    %ebp,%edx
mov    %r12,%rcx
call   10e0 <fwrite@plt>
cmp    %ebp,%eax
je     1330 <main+0x160>
mov    %r13,%rdi
xor    %eax,%eax
call   1090 <err_exit@plt>
jmp    1330 <main+0x160>

LLVM IR (-O0):
@EXIT_FAILURE = global i32 0
@.str = [14 x i8] c"malloc error\0A\00"
@.str.1 = [2 x i8] c"r\00"
@.str.2 = [20 x i8] c"fopen %s error: %s\0A\00"
@errno = global i32 0
@.str.3 = [2 x i8] c"w\00"
@.str.4 = [14 x i8] c"fwrite error\0A\00"
@.str.5 = [19 x i8] c"getline error: %s\0A\00"
@EXIT_SUCCESS = global i32 0
define i32 @main(i32 %0, i8** %1) {
%3 = alloca i32
%4 = alloca i32
%5 = alloca i8**
%6 = alloca i8*
%7 = alloca i8*
%8 = alloca i32*
%9 = alloca i32*
%10 = alloca i32
%11 = alloca i8*
%12 = alloca i64
store i32 0, i32* %3
store i32 %0, i32* %4
store i8** %1, i8*** %5
%13 = load i32, i32* %4
%14 = icmp ne i32 %13, 3
br i1 %14, label %15, label %19
15: ; preds = %2
%16 = call i32 (...) @usage()
%17 = load i32, i32* @EXIT_FAILURE
%18 = call i32 @exit(i32 %17)
unreachable
19: ; preds = %2
%20 = load i8**, i8*** %5
%21 = getelementptr inbounds i8*, i8** %20, i64 1
%22 = load i8*, i8** %21
store i8* %22, i8** %6
%23 = load i8**, i8*** %5
%24 = getelementptr inbounds i8*, i8** %23, i64 2
%25 = load i8*, i8** %24
store i8* %25, i8** %7
store i64 128, i64* %12
%26 = load i64, i64* %12
%27 = mul i64 1, %26
%28 = trunc i64 %27 to i32
%29 = call i64 @malloc(i32 %28)
%30 = inttoptr i64 %29 to i8*
store i8* %30, i8** %11
%31 = load i8*, i8** %11
%32 = icmp eq i8* %31, null
br i1 %32, label %33, label %35
33: ; preds = %19
%34 = call i32 (i8*, ...) @err_exit(i8* getelementptr inbounds ([14 x i8], [14 x i8]* @.str, i64 0, i64 0))
br label %35
35: ; preds = %33, %19
%36 = load i8*, i8** %6
%37 = call i32* @fopen(i8* %36, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.1, i64 0, i64 0))
store i32* %37, i32** %8
%38 = load i32*, i32** %8
%39 = icmp eq i32* %38, null
br i1 %39, label %40, label %45
40: ; preds = %35
%41 = load i8*, i8** %6
%42 = load i32, i32* @errno
%43 = call i32 @strerror(i32 %42)
%44 = call i32 (i8*, ...) @err_exit(i8* getelementptr inbounds ([20 x i8], [20 x i8]* @.str.2, i64 0, i64 0), i8* %41, i32 %43)
br label %45
45: ; preds = %40, %35
%46 = load i8*, i8** %7
%47 = call i32* @fopen(i8* %46, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.3, i64 0, i64 0))
store i32* %47, i32** %9
%48 = load i32*, i32** %9
%49 = icmp eq i32* %48, null
br i1 %49, label %50, label %55
50: ; preds = %45
%51 = load i8*, i8** %7
%52 = load i32, i32* @errno
%53 = call i32 @strerror(i32 %52)
%54 = call i32 (i8*, ...) @err_exit(i8* getelementptr inbounds ([20 x i8], [20 x i8]* @.str.2, i64 0, i64 0), i8* %51, i32 %53)
br label %55
55: ; preds = %50, %45
%56 = load i32*, i32** %8
%57 = call i32 @clearerr(i32* %56)
br label %58
58: ; preds = %71, %55
%59 = load i32*, i32** %8
%60 = call i32 @getline(i8** %11, i64* %12, i32* %59)
store i32 %60, i32* %10
%61 = icmp ne i32 %60, -1
br i1 %61, label %62, label %72
62: ; preds = %58
%63 = load i8*, i8** %11
%64 = load i32, i32* %10
%65 = load i32*, i32** %9
%66 = call i32 @fwrite(i8* %63, i32 1, i32 %64, i32* %65)
%67 = load i32, i32* %10
%68 = icmp ne i32 %66, %67
br i1 %68, label %69, label %71
69: ; preds = %62
%70 = call i32 (i8*, ...) @err_exit(i8* getelementptr inbounds ([14 x i8], [14 x i8]* @.str.4, i64 0, i64 0))
br label %71
71: ; preds = %69, %62
br label %58
72: ; preds = %58
%73 = load i32*, i32** %8
%74 = call i64 @ferror(i32* %73)
%75 = icmp ne i64 %74, 0
br i1 %75, label %76, label %80
76: ; preds = %72
%77 = load i32, i32* @errno
%78 = call i32 @strerror(i32 %77)
%79 = call i32 @err_log(i8* getelementptr inbounds ([19 x i8], [19 x i8]* @.str.5, i64 0, i64 0), i32 %78)
br label %80
80: ; preds = %76, %72
%81 = load i8*, i8** %11
%82 = call i32 @free(i8* %81)
%83 = load i32*, i32** %8
%84 = call i32 @fclose(i32* %83)
%85 = load i32*, i32** %9
%86 = call i32 @fclose(i32* %85)
%87 = load i32, i32* @EXIT_SUCCESS
%88 = call i32 @exit(i32 %87)
unreachable
}

LLVM IR (-O2):
@EXIT_FAILURE = global i32 0
@.str = [14 x i8] c"malloc error\0A\00"
@.str.1 = [2 x i8] c"r\00"
@.str.2 = [20 x i8] c"fopen %s error: %s\0A\00"
@errno = global i32 0
@.str.3 = [2 x i8] c"w\00"
@.str.4 = [14 x i8] c"fwrite error\0A\00"
@.str.5 = [19 x i8] c"getline error: %s\0A\00"
@EXIT_SUCCESS = global i32 0
define i32 @main(i32 %0, i8** nocapture %1) {
%3 = alloca i8*
%4 = alloca i64
%5 = bitcast i8** %3 to i8*
%6 = bitcast i64* %4 to i8*
%7 = icmp eq i32 %0, 3
br i1 %7, label %12, label %8
8: ; preds = %2
%9 = tail call i32 (...) @usage()
%10 = load i32, i32* @EXIT_FAILURE
%11 = tail call i32 @exit(i32 %10)
unreachable
12: ; preds = %2
%13 = getelementptr inbounds i8*, i8** %1, i64 1
%14 = load i8*, i8** %13
%15 = getelementptr inbounds i8*, i8** %1, i64 2
%16 = load i8*, i8** %15
store i64 128, i64* %4
%17 = tail call i64 @malloc(i32 128)
%18 = inttoptr i64 %17 to i8*
store i8* %18, i8** %3
%19 = icmp eq i64 %17, 0
br i1 %19, label %20, label %22
20: ; preds = %12
%21 = tail call i32 (i8*, ...) @err_exit(i8* getelementptr inbounds ([14 x i8], [14 x i8]* @.str, i64 0, i64 0))
br label %22
22: ; preds = %20, %12
%23 = tail call i32* @fopen(i8* %14, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.1, i64 0, i64 0))
%24 = icmp eq i32* %23, null
br i1 %24, label %25, label %29
25: ; preds = %22
%26 = load i32, i32* @errno
%27 = tail call i32 @strerror(i32 %26)
%28 = tail call i32 (i8*, ...) @err_exit(i8* getelementptr inbounds ([20 x i8], [20 x i8]* @.str.2, i64 0, i64 0), i8* %14, i32 %27)
br label %29
29: ; preds = %25, %22
%30 = tail call i32* @fopen(i8* %16, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.3, i64 0, i64 0))
%31 = icmp eq i32* %30, null
br i1 %31, label %32, label %36
32: ; preds = %29
%33 = load i32, i32* @errno
%34 = tail call i32 @strerror(i32 %33)
%35 = tail call i32 (i8*, ...) @err_exit(i8* getelementptr inbounds ([20 x i8], [20 x i8]* @.str.2, i64 0, i64 0), i8* %16, i32 %34)
br label %36
36: ; preds = %32, %29
%37 = tail call i32 @clearerr(i32* %23)
%38 = call i32 @getline(i8** %3, i64* %4, i32* %23)
%39 = icmp eq i32 %38, -1
br i1 %39, label %50, label %40
40: ; preds = %36, %47
%41 = phi i32 [ %48, %47 ], [ %38, %36 ]
%42 = load i8*, i8** %3
%43 = call i32 @fwrite(i8* %42, i32 1, i32 %41, i32* %30)
%44 = icmp eq i32 %43, %41
br i1 %44, label %47, label %45
45: ; preds = %40
%46 = call i32 (i8*, ...) @err_exit(i8* getelementptr inbounds ([14 x i8], [14 x i8]* @.str.4, i64 0, i64 0))
br label %47
47: ; preds = %45, %40
%48 = call i32 @getline(i8** %3, i64* %4, i32* %23)
%49 = icmp eq i32 %48, -1
br i1 %49, label %50, label %40
50: ; preds = %47, %36
%51 = call i64 @ferror(i32* %23)
%52 = icmp eq i64 %51, 0
br i1 %52, label %57, label %53
53: ; preds = %50
%54 = load i32, i32* @errno
%55 = call i32 @strerror(i32 %54)
%56 = call i32 @err_log(i8* getelementptr inbounds ([19 x i8], [19 x i8]* @.str.5, i64 0, i64 0), i32 %55)
br label %57
57: ; preds = %53, %50
%58 = load i8*, i8** %3
%59 = call i32 @free(i8* %58)
%60 = call i32 @fclose(i32* %23)
%61 = call i32 @fclose(i32* %30)
%62 = load i32, i32* @EXIT_SUCCESS
%63 = call i32 @exit(i32 %62)
unreachable
}