#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 *);
int /*<<< orphan*/ fputs(char *, int /*<<< orphan*/ *);
int /*<<< orphan*/ printf(char *);
int /*<<< orphan*/ stderr;
int /*<<< orphan*/ stdin;
int main(int argc, char **argv) {
  if (argc < 2) {
    fprintf(stderr, "Incorrect number of params");
    return 1;
  }
  char line[80];
  FILE *outfile = fopen(argv[1], "w");
  printf("Enter lines:\n");
  while (fgets(line, 80, stdin)) {
    fputs(line, outfile);
  }
  fclose(outfile);
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x70,%rsp
movl   $0x0,-0x4(%rbp)
mov    %edi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
cmpl   $0x2,-0x8(%rbp)
jge    11a1 <main+0x41>
mov    0x2e51(%rip),%rax
mov    (%rax),%edi
lea    0xe70(%rip),%rsi
call   1070 <fprintf@plt>
movl   $0x1,-0x4(%rbp)
jmp    1208 <main+0xa8>
mov    -0x10(%rbp),%rax
mov    0x8(%rax),%rdi
lea    0xe6b(%rip),%rsi
call   1080 <fopen@plt>
mov    %rax,-0x68(%rbp)
lea    0xe5d(%rip),%rdi
call   1040 <printf@plt>
lea    -0x60(%rbp),%rdi
mov    0x2e18(%rip),%rax
mov    (%rax),%edx
mov    $0x50,%esi
call   1060 <fgets@plt>
cmp    $0x0,%rax
je     11f8 <main+0x98>
lea    -0x60(%rbp),%rdi
mov    -0x68(%rbp),%rsi
call   1050 <fputs@plt>
jmp    11c5 <main+0x65>
mov    -0x68(%rbp),%rdi
call   1030 <fclose@plt>
movl   $0x0,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x70,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %r15
push   %r14
push   %rbx
sub    $0x50,%rsp
cmp    $0x1,%edi
jg     118a <main+0x2a>
mov    0x2e63(%rip),%rax
mov    (%rax),%edi
lea    0xe82(%rip),%rsi
call   1070 <fprintf@plt>
mov    $0x1,%eax
jmp    11fa <main+0x9a>
mov    0x8(%rsi),%rdi
lea    0xe86(%rip),%rsi
call   1080 <fopen@plt>
mov    %rax,%r14
lea    0xe79(%rip),%rdi
call   1030 <puts@plt>
mov    0x2e38(%rip),%r15
mov    (%r15),%edx
mov    %rsp,%rdi
mov    $0x50,%esi
call   1060 <fgets@plt>
test   %rax,%rax
je     11f0 <main+0x90>
mov    %rsp,%rbx
nopl   0x0(%rax,%rax,1)
mov    %rbx,%rdi
mov    %r14,%rsi
call   1050 <fputs@plt>
mov    (%r15),%edx
mov    %rbx,%rdi
mov    $0x50,%esi
call   1060 <fgets@plt>
test   %rax,%rax
jne    11d0 <main+0x70>
mov    %r14,%rdi
call   1040 <fclose@plt>
xor    %eax,%eax
add    $0x50,%rsp
pop    %rbx
pop    %r14
pop    %r15
ret

LLVM IR (-O0):
@stderr = global i32 0
@.str = [27 x i8] c"Incorrect number of params\00"
@.str.1 = [2 x i8] c"w\00"
@.str.2 = [14 x i8] c"Enter lines:\0A\00"
@stdin = global i32 0
define i32 @main(i32 %0, i8** %1) {
%3 = alloca i32
%4 = alloca i32
%5 = alloca i8**
%6 = alloca [80 x i8]
%7 = alloca i32*
store i32 0, i32* %3
store i32 %0, i32* %4
store i8** %1, i8*** %5
%8 = load i32, i32* %4
%9 = icmp slt i32 %8, 2
br i1 %9, label %10, label %13
10: ; preds = %2
%11 = load i32, i32* @stderr
%12 = call i32 @fprintf(i32 %11, i8* getelementptr inbounds ([27 x i8], [27 x i8]* @.str, i64 0, i64 0))
store i32 1, i32* %3
br label %31
13: ; preds = %2
%14 = load i8**, i8*** %5
%15 = getelementptr inbounds i8*, i8** %14, i64 1
%16 = load i8*, i8** %15
%17 = call i32* @fopen(i8* %16, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.1, i64 0, i64 0))
store i32* %17, i32** %7
%18 = call i32 @printf(i8* getelementptr inbounds ([14 x i8], [14 x i8]* @.str.2, i64 0, i64 0))
br label %19
19: ; preds = %24, %13
%20 = getelementptr inbounds [80 x i8], [80 x i8]* %6, i64 0, i64 0
%21 = load i32, i32* @stdin
%22 = call i64 @fgets(i8* %20, i32 80, i32 %21)
%23 = icmp ne i64 %22, 0
br i1 %23, label %24, label %28
24: ; preds = %19
%25 = getelementptr inbounds [80 x i8], [80 x i8]* %6, i64 0, i64 0
%26 = load i32*, i32** %7
%27 = call i32 @fputs(i8* %25, i32* %26)
br label %19
28: ; preds = %19
%29 = load i32*, i32** %7
%30 = call i32 @fclose(i32* %29)
store i32 0, i32* %3
br label %31
31: ; preds = %28, %10
%32 = load i32, i32* %3
ret i32 %32
}

LLVM IR (-O2):
@stderr = global i32 0
@.str = [27 x i8] c"Incorrect number of params\00"
@.str.1 = [2 x i8] c"w\00"
@stdin = global i32 0
@str = [13 x i8] c"Enter lines:\00"
define i32 @main(i32 %0, i8** nocapture %1) {
%3 = alloca [80 x i8]
%4 = icmp slt i32 %0, 2
br i1 %4, label %5, label %8
5: ; preds = %2
%6 = load i32, i32* @stderr
%7 = tail call i32 @fprintf(i32 %6, i8* getelementptr inbounds ([27 x i8], [27 x i8]* @.str, i64 0, i64 0))
br label %24
8: ; preds = %2
%9 = getelementptr inbounds [80 x i8], [80 x i8]* %3, i64 0, i64 0
%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 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([13 x i8], [13 x i8]* @str, i64 0, i64 0))
%14 = load i32, i32* @stdin
%15 = call i64 @fgets(i8* %9, i32 80, i32 %14)
%16 = icmp eq i64 %15, 0
br i1 %16, label %22, label %17
17: ; preds = %8, %17
%18 = call i32 @fputs(i8* %9, i32* %12)
%19 = load i32, i32* @stdin
%20 = call i64 @fgets(i8* %9, i32 80, i32 %19)
%21 = icmp eq i64 %20, 0
br i1 %21, label %22, label %17
22: ; preds = %17, %8
%23 = call i32 @fclose(i32* %12)
br label %24
24: ; preds = %22, %5
%25 = phi i32 [ 1, %5 ], [ 0, %22 ]
ret i32 %25
}