#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 */
struct marker {
  int dummy;
};

/* Variables and functions */
int /*<<< orphan*/ chomp(char *);
int /*<<< orphan*/ expander(char *, struct marker *);
int getline(char **, size_t *, int /*<<< orphan*/);
int /*<<< orphan*/ stdin;
int getfilenamefromstdin(struct marker *p) {
  int rc = 0;
  char line[4096];
  char *buffer;
  size_t size = 4096;
  int b;
  buffer = line;
  b = getline(&buffer, &size, stdin);
  while (b > 0) {
    chomp(buffer);
    expander(buffer, p);
    b = getline(&buffer, &size, stdin);
  }
  return rc;
}


x86 assembly (clang, -O0):
<getfilenamefromstdin>:
push   %rbp
mov    %rsp,%rbp
sub    $0x1030,%rsp
mov    %rdi,-0x8(%rbp)
movl   $0x0,-0xc(%rbp)
movq   $0x1000,-0x1020(%rbp)
lea    -0x1010(%rbp),%rax
mov    %rax,-0x1018(%rbp)
mov    0x2e82(%rip),%rax
mov    (%rax),%edx
lea    -0x1018(%rbp),%rdi
lea    -0x1020(%rbp),%rsi
call   1050 <getline@plt>
mov    %eax,-0x1024(%rbp)
cmpl   $0x0,-0x1024(%rbp)
jle    11d1 <getfilenamefromstdin+0xa1>
mov    -0x1018(%rbp),%rdi
call   1030 <chomp@plt>
mov    -0x1018(%rbp),%rdi
mov    -0x8(%rbp),%rsi
call   1040 <expander@plt>
mov    0x2e37(%rip),%rax
mov    (%rax),%edx
lea    -0x1018(%rbp),%rdi
lea    -0x1020(%rbp),%rsi
call   1050 <getline@plt>
mov    %eax,-0x1024(%rbp)
jmp    1181 <getfilenamefromstdin+0x51>
mov    -0xc(%rbp),%eax
add    $0x1030,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<getfilenamefromstdin>:
push   %r15
push   %r14
push   %r12
push   %rbx
sub    $0x1018,%rsp
mov    %rdi,%rbx
movq   $0x1000,0x8(%rsp)
lea    0x10(%rsp),%rax
mov    %rax,(%rsp)
mov    0x2e8e(%rip),%r12
mov    (%r12),%edx
mov    %rsp,%rdi
lea    0x8(%rsp),%rsi
call   1050 <getline@plt>
test   %eax,%eax
jle    11a8 <getfilenamefromstdin+0x78>
mov    %rsp,%r14
lea    0x8(%rsp),%r15
nopw   0x0(%rax,%rax,1)
mov    (%rsp),%rdi
call   1030 <chomp@plt>
mov    (%rsp),%rdi
mov    %rbx,%rsi
call   1040 <expander@plt>
mov    (%r12),%edx
mov    %r14,%rdi
mov    %r15,%rsi
call   1050 <getline@plt>
test   %eax,%eax
jg     1180 <getfilenamefromstdin+0x50>
xor    %eax,%eax
add    $0x1018,%rsp
pop    %rbx
pop    %r12
pop    %r14
pop    %r15
ret

LLVM IR (-O0):
%struct.marker = type { i32 }
@stdin = global i32 0
define i32 @getfilenamefromstdin(%struct.marker* %0) {
%2 = alloca %struct.marker*
%3 = alloca i32
%4 = alloca [4096 x i8]
%5 = alloca i8*
%6 = alloca i64
%7 = alloca i32
store %struct.marker* %0, %struct.marker** %2
store i32 0, i32* %3
store i64 4096, i64* %6
%8 = getelementptr inbounds [4096 x i8], [4096 x i8]* %4, i64 0, i64 0
store i8* %8, i8** %5
%9 = load i32, i32* @stdin
%10 = call i32 @getline(i8** %5, i64* %6, i32 %9)
store i32 %10, i32* %7
br label %11
11: ; preds = %14, %1
%12 = load i32, i32* %7
%13 = icmp sgt i32 %12, 0
br i1 %13, label %14, label %22
14: ; preds = %11
%15 = load i8*, i8** %5
%16 = call i32 @chomp(i8* %15)
%17 = load i8*, i8** %5
%18 = load %struct.marker*, %struct.marker** %2
%19 = call i32 @expander(i8* %17, %struct.marker* %18)
%20 = load i32, i32* @stdin
%21 = call i32 @getline(i8** %5, i64* %6, i32 %20)
store i32 %21, i32* %7
br label %11
22: ; preds = %11
%23 = load i32, i32* %3
ret i32 %23
}

LLVM IR (-O2):
%struct.marker = type { i32 }
@stdin = global i32 0
define i32 @getfilenamefromstdin(%struct.marker* %0) {
%2 = alloca [4096 x i8]
%3 = alloca i8*
%4 = alloca i64
%5 = getelementptr inbounds [4096 x i8], [4096 x i8]* %2, i64 0, i64 0
%6 = bitcast i8** %3 to i8*
%7 = bitcast i64* %4 to i8*
store i64 4096, i64* %4
store i8* %5, i8** %3
%8 = load i32, i32* @stdin
%9 = call i32 @getline(i8** %3, i64* %4, i32 %8)
%10 = icmp sgt i32 %9, 0
br i1 %10, label %11, label %19
11: ; preds = %1, %11
%12 = load i8*, i8** %3
%13 = call i32 @chomp(i8* %12)
%14 = load i8*, i8** %3
%15 = call i32 @expander(i8* %14, %struct.marker* %0)
%16 = load i32, i32* @stdin
%17 = call i32 @getline(i8** %3, i64* %4, i32 %16)
%18 = icmp sgt i32 %17, 0
br i1 %18, label %11, label %19
19: ; preds = %11, %1
ret i32 0
}