#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 */
typedef int /*<<< orphan*/ FILE;

/* Variables and functions */
int /*<<< orphan*/ feof(int /*<<< orphan*/ *);
int /*<<< orphan*/ fscanf(int /*<<< orphan*/ *, char *, unsigned int *);
char getc(int /*<<< orphan*/ *);
int /*<<< orphan*/ isxdigit(char);
int /*<<< orphan*/ ungetc(char, int /*<<< orphan*/ *);
unsigned int GetAddr(FILE *fp) {
  char c;
  unsigned int address;
  do {
    c = getc(fp);
    if (c == '#')
      do {
        c = getc(fp);
      } while (c != '\n');
  } while (!isxdigit(c) && !feof(fp));
  ungetc(c, fp);
  fscanf(fp, "%x\n", &address);
  return (address);
}


x86 assembly (clang, -O0):
<GetAddr>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %rdi,-0x8(%rbp)
mov    -0x8(%rbp),%rdi
call   1070 <getc@plt>
mov    %al,-0x9(%rbp)
movsbl -0x9(%rbp),%eax
cmp    $0x23,%eax
jne    1198 <GetAddr+0x48>
jmp    117a <GetAddr+0x2a>
mov    -0x8(%rbp),%rdi
call   1070 <getc@plt>
mov    %al,-0x9(%rbp)
movsbl -0x9(%rbp),%eax
cmp    $0xa,%eax
jne    117a <GetAddr+0x2a>
jmp    1198 <GetAddr+0x48>
jmp    119d <GetAddr+0x4d>
movsbl -0x9(%rbp),%edi
call   1060 <isxdigit@plt>
mov    %eax,%ecx
xor    %eax,%eax
cmp    $0x0,%ecx
mov    %al,-0x11(%rbp)
jne    11ca <GetAddr+0x7a>
mov    -0x8(%rbp),%rdi
call   1040 <feof@plt>
cmp    $0x0,%eax
setne  %al
xor    $0xff,%al
mov    %al,-0x11(%rbp)
mov    -0x11(%rbp),%al
test   $0x1,%al
jne    115c <GetAddr+0xc>
mov    -0x9(%rbp),%al
mov    -0x8(%rbp),%rsi
movsbl %al,%edi
call   1050 <ungetc@plt>
mov    -0x8(%rbp),%rdi
lea    0xe11(%rip),%rsi
lea    -0x10(%rbp),%rdx
call   1030 <fscanf@plt>
mov    -0x10(%rbp),%eax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<GetAddr>:
push   %rbp
push   %rbx
push   %rax
mov    %rdi,%rbx
cs nopw 0x0(%rax,%rax,1)
mov    %rbx,%rdi
call   1070 <getc@plt>
cmp    $0x23,%al
jne    117e <GetAddr+0x2e>
nopl   0x0(%rax)
mov    %rbx,%rdi
call   1070 <getc@plt>
cmp    $0xa,%al
jne    1170 <GetAddr+0x20>
mov    $0xa,%al
movsbl %al,%ebp
mov    %ebp,%edi
call   1060 <isxdigit@plt>
test   %eax,%eax
jne    1198 <GetAddr+0x48>
mov    %rbx,%rdi
call   1040 <feof@plt>
test   %eax,%eax
je     1160 <GetAddr+0x10>
mov    %ebp,%edi
mov    %rbx,%rsi
call   1050 <ungetc@plt>
lea    0xe57(%rip),%rsi
lea    0x4(%rsp),%rdx
mov    %rbx,%rdi
call   1030 <fscanf@plt>
mov    0x4(%rsp),%eax
add    $0x8,%rsp
pop    %rbx
pop    %rbp
ret

LLVM IR (-O0):
@.str = [4 x i8] c"%x\0A\00"
define i32 @GetAddr(i32* %0) {
%2 = alloca i32*
%3 = alloca i8
%4 = alloca i32
store i32* %0, i32** %2
br label %5
5: ; preds = %30, %1
%6 = load i32*, i32** %2
%7 = call signext i8 @getc(i32* %6)
store i8 %7, i8* %3
%8 = load i8, i8* %3
%9 = sext i8 %8 to i32
%10 = icmp eq i32 %9, 35
br i1 %10, label %11, label %20
11: ; preds = %5
br label %12
12: ; preds = %15, %11
%13 = load i32*, i32** %2
%14 = call signext i8 @getc(i32* %13)
store i8 %14, i8* %3
br label %15
15: ; preds = %12
%16 = load i8, i8* %3
%17 = sext i8 %16 to i32
%18 = icmp ne i32 %17, 10
br i1 %18, label %12, label %19
19: ; preds = %15
br label %20
20: ; preds = %19, %5
br label %21
21: ; preds = %20
%22 = load i8, i8* %3
%23 = call i32 @isxdigit(i8 signext %22)
%24 = icmp ne i32 %23, 0
br i1 %24, label %30, label %25
25: ; preds = %21
%26 = load i32*, i32** %2
%27 = call i32 @feof(i32* %26)
%28 = icmp ne i32 %27, 0
%29 = xor i1 %28, true
br label %30
30: ; preds = %25, %21
%31 = phi i1 [ false, %21 ], [ %29, %25 ]
br i1 %31, label %5, label %32
32: ; preds = %30
%33 = load i8, i8* %3
%34 = load i32*, i32** %2
%35 = call i32 @ungetc(i8 signext %33, i32* %34)
%36 = load i32*, i32** %2
%37 = call i32 @fscanf(i32* %36, i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str, i64 0, i64 0), i32* %4)
%38 = load i32, i32* %4
ret i32 %38
}

LLVM IR (-O2):
@.str = [4 x i8] c"%x\0A\00"
define i32 @GetAddr(i32* nocapture %0) {
%2 = alloca i32
%3 = bitcast i32* %2 to i8*
br label %4
4: ; preds = %14, %1
%5 = tail call signext i8 @getc(i32* %0)
%6 = icmp eq i8 %5, 35
br i1 %6, label %7, label %10
7: ; preds = %4, %7
%8 = tail call signext i8 @getc(i32* %0)
%9 = icmp eq i8 %8, 10
br i1 %9, label %10, label %7
10: ; preds = %7, %4
%11 = phi i8 [ %5, %4 ], [ 10, %7 ]
%12 = tail call i32 @isxdigit(i8 signext %11)
%13 = icmp eq i32 %12, 0
br i1 %13, label %14, label %17
14: ; preds = %10
%15 = tail call i32 @feof(i32* %0)
%16 = icmp eq i32 %15, 0
br i1 %16, label %4, label %17
17: ; preds = %10, %14
%18 = tail call i32 @ungetc(i8 signext %11, i32* %0)
%19 = call i32 @fscanf(i32* %0, i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str, i64 0, i64 0), i32* %2)
%20 = load i32, i32* %2
ret i32 %20
}