#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 */
scalar_t__ EINTR;
scalar_t__ errno;
int /*<<< orphan*/ *fgets(char *, int, int /*<<< orphan*/);
int /*<<< orphan*/ printf(char *);
int /*<<< orphan*/ stdin;
char *get_line(char *s, int size) {
  printf("ish$ ");
  while (fgets(s, size, stdin) == NULL) {
    if (errno == EINTR)
      continue;
    return NULL;
  }
  return s;
}


x86 assembly (clang, -O0):
<get_line>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %rdi,-0x10(%rbp)
mov    %esi,-0x14(%rbp)
lea    0xeca(%rip),%rdi
call   1030 <printf@plt>
mov    -0x10(%rbp),%rdi
mov    -0x14(%rbp),%esi
mov    0x2e9f(%rip),%rax
mov    (%rax),%edx
call   1040 <fgets@plt>
cmp    $0x0,%rax
jne    1186 <get_line+0x66>
mov    0x2e77(%rip),%rax
mov    (%rax),%rax
mov    0x2e65(%rip),%rcx
cmp    (%rcx),%rax
jne    1179 <get_line+0x59>
jmp    113b <get_line+0x1b>
movq   $0x0,-0x8(%rbp)
jmp    118e <get_line+0x6e>
mov    -0x10(%rbp),%rax
mov    %rax,-0x8(%rbp)
mov    -0x8(%rbp),%rax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<get_line>:
push   %rbp
push   %r15
push   %r14
push   %r12
push   %rbx
mov    %esi,%ebp
mov    %rdi,%rbx
lea    0xecc(%rip),%rdi
call   1030 <printf@plt>
mov    0x2ea8(%rip),%r14
mov    0x2e91(%rip),%r15
mov    0x2e82(%rip),%r12
xchg   %ax,%ax
mov    (%r14),%edx
mov    %rbx,%rdi
mov    %ebp,%esi
call   1040 <fgets@plt>
test   %rax,%rax
jne    116d <get_line+0x4d>
mov    (%r15),%rax
cmp    (%r12),%rax
je     1150 <get_line+0x30>
xor    %ebx,%ebx
mov    %rbx,%rax
pop    %rbx
pop    %r12
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
@.str = [6 x i8] c"ish$ \00"
@stdin = global i32 0
@errno = global i64 0
@EINTR = global i64 0
define i8* @get_line(i8* %0, i32 %1) {
%3 = alloca i8*
%4 = alloca i8*
%5 = alloca i32
store i8* %0, i8** %4
store i32 %1, i32* %5
%6 = call i32 @printf(i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str, i64 0, i64 0))
br label %7
7: ; preds = %17, %2
%8 = load i8*, i8** %4
%9 = load i32, i32* %5
%10 = load i32, i32* @stdin
%11 = call i32* @fgets(i8* %8, i32 %9, i32 %10)
%12 = icmp eq i32* %11, null
br i1 %12, label %13, label %19
13: ; preds = %7
%14 = load i64, i64* @errno
%15 = load i64, i64* @EINTR
%16 = icmp eq i64 %14, %15
br i1 %16, label %17, label %18
17: ; preds = %13
br label %7
18: ; preds = %13
store i8* null, i8** %3
br label %21
19: ; preds = %7
%20 = load i8*, i8** %4
store i8* %20, i8** %3
br label %21
21: ; preds = %19, %18
%22 = load i8*, i8** %3
ret i8* %22
}

LLVM IR (-O2):
@.str = [6 x i8] c"ish$ \00"
@stdin = global i32 0
@errno = global i64 0
@EINTR = global i64 0
define i8* @get_line(i8* %0, i32 %1) {
%3 = tail call i32 @printf(i8* dereferenceable(1) getelementptr inbounds ([6 x i8], [6 x i8]* @.str, i64 0, i64 0))
br label %4
4: ; preds = %8, %2
%5 = load i32, i32* @stdin
%6 = tail call i32* @fgets(i8* %0, i32 %1, i32 %5)
%7 = icmp eq i32* %6, null
br i1 %7, label %8, label %12
8: ; preds = %4
%9 = load i64, i64* @errno
%10 = load i64, i64* @EINTR
%11 = icmp eq i64 %9, %10
br i1 %11, label %4, label %12
12: ; preds = %4, %8
%13 = phi i8* [ null, %8 ], [ %0, %4 ]
ret i8* %13
}