#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 */
char *expand(char *);
char *laststring(char *, int *, int /*<<< orphan*/);
int /*<<< orphan*/ printf(char *);
char *snarf(char *linebuf, int *flag, int usembox) {
  char *cp;
  *flag = 1;
  if ((cp = laststring(linebuf, flag, 0)) == NULL) {
    if (usembox) {
      *flag = 0;
      return expand("&");
    } else {
      printf(("No file specified.\n"));
      return NULL;
    }
  }
  return (cp);
}


x86 assembly (clang, -O0):
<snarf>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
mov    %rdi,-0x10(%rbp)
mov    %rsi,-0x18(%rbp)
mov    %edx,-0x1c(%rbp)
mov    -0x18(%rbp),%rax
movl   $0x1,(%rax)
mov    -0x10(%rbp),%rdi
mov    -0x18(%rbp),%rsi
xor    %edx,%edx
call   1040 <laststring@plt>
mov    %rax,-0x28(%rbp)
cmp    $0x0,%rax
jne    11ac <snarf+0x7c>
cmpl   $0x0,-0x1c(%rbp)
je     1193 <snarf+0x63>
mov    -0x18(%rbp),%rax
movl   $0x0,(%rax)
lea    0xe7b(%rip),%rdi
call   1050 <expand@plt>
mov    %rax,-0x8(%rbp)
jmp    11b4 <snarf+0x84>
lea    0xe68(%rip),%rdi
call   1030 <printf@plt>
movq   $0x0,-0x8(%rbp)
jmp    11b4 <snarf+0x84>
mov    -0x28(%rbp),%rax
mov    %rax,-0x8(%rbp)
mov    -0x8(%rbp),%rax
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<snarf>:
push   %rbp
push   %rbx
push   %rax
mov    %edx,%ebp
mov    %rsi,%rbx
movl   $0x1,(%rsi)
xor    %edx,%edx
call   1040 <laststring@plt>
test   %rax,%rax
je     1151 <snarf+0x21>
add    $0x8,%rsp
pop    %rbx
pop    %rbp
ret
test   %ebp,%ebp
je     116d <snarf+0x3d>
movl   $0x0,(%rbx)
lea    0xe9e(%rip),%rdi
add    $0x8,%rsp
pop    %rbx
pop    %rbp
jmp    1050 <expand@plt>
lea    0xe8e(%rip),%rdi
call   1030 <puts@plt>
xor    %eax,%eax
jmp    114a <snarf+0x1a>

LLVM IR (-O0):
@.str = [2 x i8] c"&\00"
@.str.1 = [20 x i8] c"No file specified.\0A\00"
define i8* @snarf(i8* %0, i32* %1, i32 %2) {
%4 = alloca i8*
%5 = alloca i8*
%6 = alloca i32*
%7 = alloca i32
%8 = alloca i8*
store i8* %0, i8** %5
store i32* %1, i32** %6
store i32 %2, i32* %7
%9 = load i32*, i32** %6
store i32 1, i32* %9
%10 = load i8*, i8** %5
%11 = load i32*, i32** %6
%12 = call i8* @laststring(i8* %10, i32* %11, i32 0)
store i8* %12, i8** %8
%13 = icmp eq i8* %12, null
br i1 %13, label %14, label %22
14: ; preds = %3
%15 = load i32, i32* %7
%16 = icmp ne i32 %15, 0
br i1 %16, label %17, label %20
17: ; preds = %14
%18 = load i32*, i32** %6
store i32 0, i32* %18
%19 = call i8* @expand(i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str, i64 0, i64 0))
store i8* %19, i8** %4
br label %24
20: ; preds = %14
%21 = call i32 @printf(i8* getelementptr inbounds ([20 x i8], [20 x i8]* @.str.1, i64 0, i64 0))
store i8* null, i8** %4
br label %24
22: ; preds = %3
%23 = load i8*, i8** %8
store i8* %23, i8** %4
br label %24
24: ; preds = %22, %20, %17
%25 = load i8*, i8** %4
ret i8* %25
}

LLVM IR (-O2):
@.str = [2 x i8] c"&\00"
@str = [19 x i8] c"No file specified.\00"
define i8* @snarf(i8* %0, i32* %1, i32 %2) {
store i32 1, i32* %1
%4 = tail call i8* @laststring(i8* %0, i32* %1, i32 0)
%5 = icmp eq i8* %4, null
br i1 %5, label %6, label %12
6: ; preds = %3
%7 = icmp eq i32 %2, 0
br i1 %7, label %10, label %8
8: ; preds = %6
store i32 0, i32* %1
%9 = tail call i8* @expand(i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str, i64 0, i64 0))
br label %12
10: ; preds = %6
%11 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([19 x i8], [19 x i8]* @str, i64 0, i64 0))
br label %12
12: ; preds = %3, %10, %8
%13 = phi i8* [ %9, %8 ], [ null, %10 ], [ %4, %3 ]
ret i8* %13
}