#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 */
scalar_t__ fgets(char *, int, int /*<<< orphan*/ *);
int /*<<< orphan*/ printf(char *, int, char *);
void show_line_numbers(FILE *in) {
  int line_count = 1;
  char line[1000];
  while (fgets(line, 1000, in)) {
    printf("%d\t%s", line_count, line);
    line_count++;
  }
}


x86 assembly (clang, -O0):
<show_line_numbers>:
push   %rbp
mov    %rsp,%rbp
sub    $0x400,%rsp
mov    %rdi,-0x8(%rbp)
movl   $0x1,-0xc(%rbp)
lea    -0x400(%rbp),%rdi
mov    -0x8(%rbp),%rdx
mov    $0x3e8,%esi
call   1040 <fgets@plt>
cmp    $0x0,%rax
je     1179 <show_line_numbers+0x59>
mov    -0xc(%rbp),%esi
lea    -0x400(%rbp),%rdx
lea    0xe9a(%rip),%rdi
call   1030 <printf@plt>
mov    -0xc(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0xc(%rbp)
jmp    1136 <show_line_numbers+0x16>
add    $0x400,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<show_line_numbers>:
push   %rbp
push   %r15
push   %r14
push   %rbx
sub    $0x3e8,%rsp
mov    %rdi,%r15
mov    %rsp,%rdi
mov    $0x3e8,%esi
mov    %r15,%rdx
call   1040 <fgets@plt>
test   %rax,%rax
je     1185 <show_line_numbers+0x65>
mov    $0x1,%ebp
lea    0xeaf(%rip),%r14
mov    %rsp,%rbx
cs nopw 0x0(%rax,%rax,1)
xchg   %ax,%ax
mov    %r14,%rdi
mov    %ebp,%esi
mov    %rbx,%rdx
call   1030 <printf@plt>
add    $0x1,%ebp
mov    %rbx,%rdi
mov    $0x3e8,%esi
mov    %r15,%rdx
call   1040 <fgets@plt>
test   %rax,%rax
jne    1160 <show_line_numbers+0x40>
add    $0x3e8,%rsp
pop    %rbx
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
@.str = [6 x i8] c"%d\09%s\00"
define void @show_line_numbers(i32* %0) {
%2 = alloca i32*
%3 = alloca i32
%4 = alloca [1000 x i8]
store i32* %0, i32** %2
store i32 1, i32* %3
br label %5
5: ; preds = %10, %1
%6 = getelementptr inbounds [1000 x i8], [1000 x i8]* %4, i64 0, i64 0
%7 = load i32*, i32** %2
%8 = call i64 @fgets(i8* %6, i32 1000, i32* %7)
%9 = icmp ne i64 %8, 0
br i1 %9, label %10, label %16
10: ; preds = %5
%11 = load i32, i32* %3
%12 = getelementptr inbounds [1000 x i8], [1000 x i8]* %4, i64 0, i64 0
%13 = call i32 @printf(i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str, i64 0, i64 0), i32 %11, i8* %12)
%14 = load i32, i32* %3
%15 = add nsw i32 %14, 1
store i32 %15, i32* %3
br label %5
16: ; preds = %5
ret void
}

LLVM IR (-O2):
@.str = [6 x i8] c"%d\09%s\00"
define void @show_line_numbers(i32* nocapture %0) {
%2 = alloca [1000 x i8]
%3 = getelementptr inbounds [1000 x i8], [1000 x i8]* %2, i64 0, i64 0
%4 = call i64 @fgets(i8* %3, i32 1000, i32* %0)
%5 = icmp eq i64 %4, 0
br i1 %5, label %12, label %6
6: ; preds = %1, %6
%7 = phi i32 [ %9, %6 ], [ 1, %1 ]
%8 = call i32 @printf(i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str, i64 0, i64 0), i32 %7, i8* %3)
%9 = add nuw nsw i32 %7, 1
%10 = call i64 @fgets(i8* %3, i32 1000, i32* %0)
%11 = icmp eq i64 %10, 0
br i1 %11, label %12, label %6
12: ; preds = %6, %1
ret void
}