#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 */

/* Variables and functions */
int /*<<< orphan*/ STDIN_FILENO;
int /*<<< orphan*/ ft_putendl(char *);
int /*<<< orphan*/ ft_strdel(char **);
scalar_t__ get_next_line(int /*<<< orphan*/, char **);
int /*<<< orphan*/ printf(char *, int, char *);
int main(int ac, char **av) {
  char *line;
  printf("hello, ac: %d, av[0]: %s\n", ac, av[0]);
  while (get_next_line(STDIN_FILENO, &line)) {
    ft_putendl(line);
    ft_strdel(&line);
  }
  return (0);
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
movl   $0x0,-0x4(%rbp)
mov    %edi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
mov    -0x8(%rbp),%esi
mov    -0x10(%rbp),%rax
mov    (%rax),%rdx
lea    0xe99(%rip),%rdi
call   1030 <printf@plt>
mov    0x2e6d(%rip),%rax
mov    (%rax),%edi
lea    -0x18(%rbp),%rsi
call   1060 <get_next_line@plt>
cmp    $0x0,%rax
je     119f <main+0x5f>
mov    -0x18(%rbp),%rdi
call   1040 <ft_putendl@plt>
lea    -0x18(%rbp),%rdi
call   1050 <ft_strdel@plt>
jmp    116c <main+0x2c>
xor    %eax,%eax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %r14
push   %rbx
push   %rax
mov    %edi,%eax
mov    (%rsi),%rdx
lea    0xeb0(%rip),%rdi
mov    %eax,%esi
call   1030 <printf@plt>
mov    0x2e82(%rip),%r14
mov    (%r14),%edi
mov    %rsp,%rsi
call   1060 <get_next_line@plt>
test   %rax,%rax
je     11a1 <main+0x61>
mov    %rsp,%rbx
cs nopw 0x0(%rax,%rax,1)
nopl   0x0(%rax,%rax,1)
mov    (%rsp),%rdi
call   1040 <ft_putendl@plt>
mov    %rbx,%rdi
call   1050 <ft_strdel@plt>
mov    (%r14),%edi
mov    %rbx,%rsi
call   1060 <get_next_line@plt>
test   %rax,%rax
jne    1180 <main+0x40>
xor    %eax,%eax
add    $0x8,%rsp
pop    %rbx
pop    %r14
ret

LLVM IR (-O0):
@.str = [26 x i8] c"hello, ac: %d, av[0]: %s\0A\00"
@STDIN_FILENO = global i32 0
define i32 @main(i32 %0, i8** %1) {
%3 = alloca i32
%4 = alloca i32
%5 = alloca i8**
%6 = alloca i8*
store i32 0, i32* %3
store i32 %0, i32* %4
store i8** %1, i8*** %5
%7 = load i32, i32* %4
%8 = load i8**, i8*** %5
%9 = getelementptr inbounds i8*, i8** %8, i64 0
%10 = load i8*, i8** %9
%11 = call i32 @printf(i8* getelementptr inbounds ([26 x i8], [26 x i8]* @.str, i64 0, i64 0), i32 %7, i8* %10)
br label %12
12: ; preds = %16, %2
%13 = load i32, i32* @STDIN_FILENO
%14 = call i64 @get_next_line(i32 %13, i8** %6)
%15 = icmp ne i64 %14, 0
br i1 %15, label %16, label %20
16: ; preds = %12
%17 = load i8*, i8** %6
%18 = call i32 @ft_putendl(i8* %17)
%19 = call i32 @ft_strdel(i8** %6)
br label %12
20: ; preds = %12
ret i32 0
}

LLVM IR (-O2):
@.str = [26 x i8] c"hello, ac: %d, av[0]: %s\0A\00"
@STDIN_FILENO = global i32 0
define i32 @main(i32 %0, i8** nocapture %1) {
%3 = alloca i8*
%4 = bitcast i8** %3 to i8*
%5 = load i8*, i8** %1
%6 = tail call i32 @printf(i8* getelementptr inbounds ([26 x i8], [26 x i8]* @.str, i64 0, i64 0), i32 %0, i8* %5)
%7 = load i32, i32* @STDIN_FILENO
%8 = call i64 @get_next_line(i32 %7, i8** %3)
%9 = icmp eq i64 %8, 0
br i1 %9, label %17, label %10
10: ; preds = %2, %10
%11 = load i8*, i8** %3
%12 = call i32 @ft_putendl(i8* %11)
%13 = call i32 @ft_strdel(i8** %3)
%14 = load i32, i32* @STDIN_FILENO
%15 = call i64 @get_next_line(i32 %14, i8** %3)
%16 = icmp eq i64 %15, 0
br i1 %16, label %17, label %10
17: ; preds = %10, %2
ret i32 0
}