#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 arreader {
  int dummy;
};

/* Variables and functions */
int /*<<< orphan*/ die(struct arreader *, char *);
char *getLongName(struct arreader *a, char *nametab, int pos) {
  if (nametab == 0)
    die(a, "No nametab");
  char *tp = nametab + pos;
  while (*tp) {
    tp++;
    if (*tp == '\n')
      *tp = 0;
  }
  return nametab + pos;
}


x86 assembly (clang, -O0):
<getLongName>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %rdi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
mov    %edx,-0x14(%rbp)
cmpq   $0x0,-0x10(%rbp)
jne    113e <getLongName+0x2e>
mov    -0x8(%rbp),%rdi
lea    0xec7(%rip),%rsi
call   1030 <die@plt>
mov    -0x10(%rbp),%rax
movslq -0x14(%rbp),%rcx
add    %rcx,%rax
mov    %rax,-0x20(%rbp)
mov    -0x20(%rbp),%rax
cmpb   $0x0,(%rax)
je     1182 <getLongName+0x72>
mov    -0x20(%rbp),%rax
add    $0x1,%rax
mov    %rax,-0x20(%rbp)
mov    -0x20(%rbp),%rax
movsbl (%rax),%eax
cmp    $0xa,%eax
jne    117d <getLongName+0x6d>
mov    -0x20(%rbp),%rax
movb   $0x0,(%rax)
jmp    114d <getLongName+0x3d>
mov    -0x10(%rbp),%rax
movslq -0x14(%rbp),%rcx
add    %rcx,%rax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<getLongName>:
push   %rbp
push   %rbx
push   %rax
mov    %edx,%ebp
mov    %rsi,%rbx
test   %rsi,%rsi
jne    1129 <getLongName+0x19>
lea    0xedc(%rip),%rsi
call   1030 <die@plt>
movslq %ebp,%rcx
lea    (%rbx,%rcx,1),%rax
cmpb   $0x0,(%rbx,%rcx,1)
je     1154 <getLongName+0x44>
add    %rbx,%rcx
add    $0x1,%rcx
nopl   (%rax)
movzbl (%rcx),%edx
test   %dl,%dl
je     1154 <getLongName+0x44>
add    $0x1,%rcx
cmp    $0xa,%dl
jne    1140 <getLongName+0x30>
movb   $0x0,-0x1(%rcx)
add    $0x8,%rsp
pop    %rbx
pop    %rbp
ret

LLVM IR (-O0):
%struct.arreader = type { i32 }
@.str = [11 x i8] c"No nametab\00"
define i8* @getLongName(%struct.arreader* %0, i8* %1, i32 %2) {
%4 = alloca %struct.arreader*
%5 = alloca i8*
%6 = alloca i32
%7 = alloca i8*
store %struct.arreader* %0, %struct.arreader** %4
store i8* %1, i8** %5
store i32 %2, i32* %6
%8 = load i8*, i8** %5
%9 = icmp eq i8* %8, null
br i1 %9, label %10, label %13
10: ; preds = %3
%11 = load %struct.arreader*, %struct.arreader** %4
%12 = call i32 @die(%struct.arreader* %11, i8* getelementptr inbounds ([11 x i8], [11 x i8]* @.str, i64 0, i64 0))
br label %13
13: ; preds = %10, %3
%14 = load i8*, i8** %5
%15 = load i32, i32* %6
%16 = sext i32 %15 to i64
%17 = getelementptr inbounds i8, i8* %14, i64 %16
store i8* %17, i8** %7
br label %18
18: ; preds = %31, %13
%19 = load i8*, i8** %7
%20 = load i8, i8* %19
%21 = icmp ne i8 %20, 0
br i1 %21, label %22, label %32
22: ; preds = %18
%23 = load i8*, i8** %7
%24 = getelementptr inbounds i8, i8* %23, i32 1
store i8* %24, i8** %7
%25 = load i8*, i8** %7
%26 = load i8, i8* %25
%27 = sext i8 %26 to i32
%28 = icmp eq i32 %27, 10
br i1 %28, label %29, label %31
29: ; preds = %22
%30 = load i8*, i8** %7
store i8 0, i8* %30
br label %31
31: ; preds = %29, %22
br label %18
32: ; preds = %18
%33 = load i8*, i8** %5
%34 = load i32, i32* %6
%35 = sext i32 %34 to i64
%36 = getelementptr inbounds i8, i8* %33, i64 %35
ret i8* %36
}

LLVM IR (-O2):
%struct.arreader = type { i32 }
@.str = [11 x i8] c"No nametab\00"
define i8* @getLongName(%struct.arreader* %0, i8* %1, i32 %2) {
%4 = icmp eq i8* %1, null
br i1 %4, label %5, label %7
5: ; preds = %3
%6 = tail call i32 @die(%struct.arreader* %0, i8* getelementptr inbounds ([11 x i8], [11 x i8]* @.str, i64 0, i64 0))
br label %7
7: ; preds = %5, %3
%8 = sext i32 %2 to i64
%9 = getelementptr inbounds i8, i8* %1, i64 %8
%10 = load i8, i8* %9
%11 = icmp eq i8 %10, 0
br i1 %11, label %17, label %12
12: ; preds = %7, %12
%13 = phi i8* [ %14, %12 ], [ %9, %7 ]
%14 = getelementptr inbounds i8, i8* %13, i64 1
%15 = load i8, i8* %14
switch i8 %15, label %12 [
i8 10, label %16
i8 0, label %17
]
16: ; preds = %12
store i8 0, i8* %14
br label %17
17: ; preds = %12, %16, %7
ret i8* %9
}