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

/* Variables and functions */
int /*<<< orphan*/ fclose(int /*<<< orphan*/ *);
int /*<<< orphan*/ *fgets(char *, int, int /*<<< orphan*/ *);
int /*<<< orphan*/ *fopen(char *, char *);
int /*<<< orphan*/ fprintf(int /*<<< orphan*/ *, char *);
int clear_newlines(char *input, char *output) {
  FILE *source = fopen(input, "r");
  FILE *target = fopen(output, "w");
  char string[256];
  while (fgets(string, sizeof(string), source) != NULL) {
    if (string[0] == '\n') {
      ;
    } else {
      fprintf(target, string);
    }
  }
  fclose(source);
  fclose(target);
}


x86 assembly (clang, -O0):
<clear_newlines>:
push   %rbp
mov    %rsp,%rbp
sub    $0x130,%rsp
mov    %rdi,-0x10(%rbp)
mov    %rsi,-0x18(%rbp)
mov    -0x10(%rbp),%rdi
lea    0xea2(%rip),%rsi
call   1060 <fopen@plt>
mov    %rax,-0x20(%rbp)
mov    -0x18(%rbp),%rdi
lea    0xe90(%rip),%rsi
call   1060 <fopen@plt>
mov    %rax,-0x28(%rbp)
lea    -0x130(%rbp),%rdi
mov    -0x20(%rbp),%rdx
mov    $0x100,%esi
call   1040 <fgets@plt>
cmp    $0x0,%rax
je     11c4 <clear_newlines+0x84>
movsbl -0x130(%rbp),%eax
cmp    $0xa,%eax
jne    11af <clear_newlines+0x6f>
jmp    11bf <clear_newlines+0x7f>
mov    -0x28(%rbp),%rdi
lea    -0x130(%rbp),%rsi
call   1050 <fprintf@plt>
jmp    117b <clear_newlines+0x3b>
mov    -0x20(%rbp),%rdi
call   1030 <fclose@plt>
mov    -0x28(%rbp),%rdi
call   1030 <fclose@plt>
mov    -0x4(%rbp),%eax
add    $0x130,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<clear_newlines>:
push   %r15
push   %r14
push   %rbx
sub    $0x100,%rsp
mov    %rsi,%rbx
lea    0xeaa(%rip),%rsi
call   1060 <fopen@plt>
mov    %rax,%r15
lea    0xe9d(%rip),%rsi
mov    %rbx,%rdi
call   1060 <fopen@plt>
mov    %rax,%r14
mov    %rsp,%rdi
mov    $0x100,%esi
mov    %r15,%rdx
call   1040 <fgets@plt>
test   %rax,%rax
je     11b8 <clear_newlines+0x78>
mov    %rsp,%rbx
jmp    11a5 <clear_newlines+0x65>
nopw   0x0(%rax,%rax,1)
mov    %rbx,%rdi
mov    $0x100,%esi
mov    %r15,%rdx
call   1040 <fgets@plt>
test   %rax,%rax
je     11b8 <clear_newlines+0x78>
cmpb   $0xa,(%rsp)
je     1190 <clear_newlines+0x50>
mov    %r14,%rdi
mov    %rbx,%rsi
call   1050 <fprintf@plt>
jmp    1190 <clear_newlines+0x50>
mov    %r15,%rdi
call   1030 <fclose@plt>
mov    %r14,%rdi
call   1030 <fclose@plt>
add    $0x100,%rsp
pop    %rbx
pop    %r14
pop    %r15
ret

LLVM IR (-O0):
@.str = [2 x i8] c"r\00"
@.str.1 = [2 x i8] c"w\00"
define i32 @clear_newlines(i8* %0, i8* %1) {
%3 = alloca i32
%4 = alloca i8*
%5 = alloca i8*
%6 = alloca i32*
%7 = alloca i32*
%8 = alloca [256 x i8]
store i8* %0, i8** %4
store i8* %1, i8** %5
%9 = load i8*, i8** %4
%10 = call i32* @fopen(i8* %9, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str, i64 0, i64 0))
store i32* %10, i32** %6
%11 = load i8*, i8** %5
%12 = call i32* @fopen(i8* %11, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.1, i64 0, i64 0))
store i32* %12, i32** %7
br label %13
13: ; preds = %28, %2
%14 = getelementptr inbounds [256 x i8], [256 x i8]* %8, i64 0, i64 0
%15 = load i32*, i32** %6
%16 = call i32* @fgets(i8* %14, i32 256, i32* %15)
%17 = icmp ne i32* %16, null
br i1 %17, label %18, label %29
18: ; preds = %13
%19 = getelementptr inbounds [256 x i8], [256 x i8]* %8, i64 0, i64 0
%20 = load i8, i8* %19
%21 = sext i8 %20 to i32
%22 = icmp eq i32 %21, 10
br i1 %22, label %23, label %24
23: ; preds = %18
br label %28
24: ; preds = %18
%25 = load i32*, i32** %7
%26 = getelementptr inbounds [256 x i8], [256 x i8]* %8, i64 0, i64 0
%27 = call i32 @fprintf(i32* %25, i8* %26)
br label %28
28: ; preds = %24, %23
br label %13
29: ; preds = %13
%30 = load i32*, i32** %6
%31 = call i32 @fclose(i32* %30)
%32 = load i32*, i32** %7
%33 = call i32 @fclose(i32* %32)
%34 = load i32, i32* %3
ret i32 %34
}

LLVM IR (-O2):
@.str = [2 x i8] c"r\00"
@.str.1 = [2 x i8] c"w\00"
define i32 @clear_newlines(i8* nocapture %0, i8* nocapture %1) {
%3 = alloca [256 x i8]
%4 = tail call i32* @fopen(i8* %0, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str, i64 0, i64 0))
%5 = tail call i32* @fopen(i8* %1, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.1, i64 0, i64 0))
%6 = getelementptr inbounds [256 x i8], [256 x i8]* %3, i64 0, i64 0
%7 = call i32* @fgets(i8* %6, i32 256, i32* %4)
%8 = icmp eq i32* %7, null
br i1 %8, label %17, label %9
9: ; preds = %2, %14
%10 = load i8, i8* %6
%11 = icmp eq i8 %10, 10
br i1 %11, label %14, label %12
12: ; preds = %9
%13 = call i32 @fprintf(i32* %5, i8* %6)
br label %14
14: ; preds = %9, %12
%15 = call i32* @fgets(i8* %6, i32 256, i32* %4)
%16 = icmp eq i32* %15, null
br i1 %16, label %17, label %9
17: ; preds = %14, %2
%18 = call i32 @fclose(i32* %4)
%19 = call i32 @fclose(i32* %5)
ret i32 undef
}