#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 */
#define EOF 128
int /*<<< orphan*/ fflush(int /*<<< orphan*/);
int /*<<< orphan*/ fputc(char, int /*<<< orphan*/);
int getc(int /*<<< orphan*/ *);
int /*<<< orphan*/ stdout;
void do_file(int n, FILE *f) {
  int c;
  while (n) {
    switch (c = getc(f)) {
    case EOF:
      return;
    case '\n':
      --n;
    default:
      fputc((char)c, stdout);
    }
  }
  fflush(stdout);
}


x86 assembly (clang, -O0):
<do_file>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %edi,-0x4(%rbp)
mov    %rsi,-0x10(%rbp)
cmpl   $0x0,-0x4(%rbp)
je     11a2 <do_file+0x72>
mov    -0x10(%rbp),%rdi
call   1050 <getc@plt>
mov    %eax,-0x14(%rbp)
mov    %eax,%ecx
mov    %ecx,-0x18(%rbp)
sub    $0xa,%eax
je     1180 <do_file+0x50>
jmp    1168 <do_file+0x38>
mov    -0x18(%rbp),%eax
sub    $0x80,%eax
jne    1189 <do_file+0x59>
jmp    117b <do_file+0x4b>
jmp    11b0 <do_file+0x80>
mov    -0x4(%rbp),%eax
add    $0xffffffff,%eax
mov    %eax,-0x4(%rbp)
mov    -0x14(%rbp),%eax
mov    0x2e4d(%rip),%rcx
mov    (%rcx),%esi
movsbl %al,%edi
call   1030 <fputc@plt>
jmp    113f <do_file+0xf>
mov    0x2e37(%rip),%rax
mov    (%rax),%edi
call   1040 <fflush@plt>
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<do_file>:
push   %rbp
push   %r14
push   %rbx
test   %edi,%edi
je     117b <do_file+0x4b>
mov    %rsi,%rbx
mov    %edi,%ebp
mov    0x2e9c(%rip),%r14
jmp    1162 <do_file+0x32>
cs nopw 0x0(%rax,%rax,1)
add    $0xffffffff,%ebp
mov    (%r14),%esi
movsbl %al,%edi
call   1030 <fputc@plt>
test   %ebp,%ebp
je     117b <do_file+0x4b>
mov    %rbx,%rdi
call   1050 <getc@plt>
cmp    $0xa,%eax
je     1150 <do_file+0x20>
cmp    $0x80,%eax
jne    1153 <do_file+0x23>
pop    %rbx
pop    %r14
pop    %rbp
ret
mov    0x2e5e(%rip),%rax
mov    (%rax),%edi
pop    %rbx
pop    %r14
pop    %rbp
jmp    1040 <fflush@plt>

LLVM IR (-O0):
@stdout = global i32 0
define void @do_file(i32 %0, i32* %1) {
%3 = alloca i32
%4 = alloca i32*
%5 = alloca i32
store i32 %0, i32* %3
store i32* %1, i32** %4
br label %6
6: ; preds = %21, %2
%7 = load i32, i32* %3
%8 = icmp ne i32 %7, 0
br i1 %8, label %9, label %22
9: ; preds = %6
%10 = load i32*, i32** %4
%11 = call i32 @getc(i32* %10)
store i32 %11, i32* %5
switch i32 %11, label %16 [
i32 128, label %12
i32 10, label %13
]
12: ; preds = %9
br label %25
13: ; preds = %9
%14 = load i32, i32* %3
%15 = add nsw i32 %14, -1
store i32 %15, i32* %3
br label %16
16: ; preds = %9, %13
%17 = load i32, i32* %5
%18 = trunc i32 %17 to i8
%19 = load i32, i32* @stdout
%20 = call i32 @fputc(i8 signext %18, i32 %19)
br label %21
21: ; preds = %16
br label %6
22: ; preds = %6
%23 = load i32, i32* @stdout
%24 = call i32 @fflush(i32 %23)
br label %25
25: ; preds = %22, %12
ret void
}

LLVM IR (-O2):
@stdout = global i32 0
define void @do_file(i32 %0, i32* nocapture %1) {
%3 = icmp eq i32 %0, 0
br i1 %3, label %15, label %4
4: ; preds = %2, %9
%5 = phi i32 [ %10, %9 ], [ %0, %2 ]
%6 = tail call i32 @getc(i32* %1)
switch i32 %6, label %9 [
i32 128, label %18
i32 10, label %7
]
7: ; preds = %4
%8 = add nsw i32 %5, -1
br label %9
9: ; preds = %4, %7
%10 = phi i32 [ %5, %4 ], [ %8, %7 ]
%11 = trunc i32 %6 to i8
%12 = load i32, i32* @stdout
%13 = tail call i32 @fputc(i8 signext %11, i32 %12)
%14 = icmp eq i32 %10, 0
br i1 %14, label %15, label %4
15: ; preds = %9, %2
%16 = load i32, i32* @stdout
%17 = tail call i32 @fflush(i32 %16)
br label %18
18: ; preds = %4, %15
ret void
}