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

/* Variables and functions */
char *getuint(char *, int /*<<< orphan*/ *);
int /*<<< orphan*/ panic(char *);
int /*<<< orphan*/ strlen(char *);
int /*<<< orphan*/ strncmp(char *, char *, int /*<<< orphan*/);
char *getuint_or_obj(char *in, uint32_t *out, int *type) {
  if (*in == '\n') {
    *type = 3;
  } else if (*in == '$') {
    in++;
    if (!strncmp("II", in, strlen("II"))) {
      in += 2;
      in = getuint(in, out);
      *type = 1;
    } else if (!strncmp("PRB", in, strlen("PRB"))) {
      *type = 2;
      in += 3;
    } else
      panic("Syntax error!\n");
  } else {
    in = getuint(in, out);
    *type = 0;
  }
  return in;
}


x86 assembly (clang, -O0):
<getuint_or_obj>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
mov    %rdi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
mov    %rdx,-0x18(%rbp)
mov    -0x8(%rbp),%rax
movsbl (%rax),%eax
cmp    $0xa,%eax
jne    1173 <getuint_or_obj+0x33>
mov    -0x18(%rbp),%rax
movl   $0x3,(%rax)
jmp    126a <getuint_or_obj+0x12a>
mov    -0x8(%rbp),%rax
movsbl (%rax),%eax
cmp    $0x24,%eax
jne    124a <getuint_or_obj+0x10a>
mov    -0x8(%rbp),%rax
add    $0x1,%rax
mov    %rax,-0x8(%rbp)
mov    -0x8(%rbp),%rax
mov    %rax,-0x20(%rbp)
lea    0xe62(%rip),%rdi
call   1040 <strlen@plt>
mov    -0x20(%rbp),%rsi
mov    %eax,%edx
lea    0xe50(%rip),%rdi
call   1030 <strncmp@plt>
cmp    $0x0,%eax
jne    11ea <getuint_or_obj+0xaa>
mov    -0x8(%rbp),%rax
add    $0x2,%rax
mov    %rax,-0x8(%rbp)
mov    -0x8(%rbp),%rdi
mov    -0x10(%rbp),%rsi
call   1060 <getuint@plt>
mov    %rax,-0x8(%rbp)
mov    -0x18(%rbp),%rax
movl   $0x1,(%rax)
jmp    1245 <getuint_or_obj+0x105>
mov    -0x8(%rbp),%rax
mov    %rax,-0x28(%rbp)
lea    0xe0a(%rip),%rdi
call   1040 <strlen@plt>
mov    -0x28(%rbp),%rsi
mov    %eax,%edx
lea    0xdf8(%rip),%rdi
call   1030 <strncmp@plt>
cmp    $0x0,%eax
jne    1234 <getuint_or_obj+0xf4>
mov    -0x18(%rbp),%rax
movl   $0x2,(%rax)
mov    -0x8(%rbp),%rax
add    $0x3,%rax
mov    %rax,-0x8(%rbp)
jmp    1240 <getuint_or_obj+0x100>
lea    0xdcc(%rip),%rdi
call   1050 <panic@plt>
jmp    1245 <getuint_or_obj+0x105>
jmp    1265 <getuint_or_obj+0x125>
mov    -0x8(%rbp),%rdi
mov    -0x10(%rbp),%rsi
call   1060 <getuint@plt>
mov    %rax,-0x8(%rbp)
mov    -0x18(%rbp),%rax
movl   $0x0,(%rax)
jmp    126a <getuint_or_obj+0x12a>
mov    -0x8(%rbp),%rax
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<getuint_or_obj>:
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
mov    %rdx,%r14
mov    %rsi,%r12
mov    %rdi,%rbx
mov    (%rdi),%al
cmp    $0x24,%al
je     1168 <getuint_or_obj+0x28>
cmp    $0xa,%al
jne    11bd <getuint_or_obj+0x7d>
movl   $0x3,(%r14)
jmp    11f4 <getuint_or_obj+0xb4>
lea    0x1(%rbx),%r15
lea    0xe8d(%rip),%r13
mov    %r13,%rdi
call   1040 <strlen@plt>
mov    %r13,%rdi
mov    %r15,%rsi
mov    %eax,%edx
call   1030 <strncmp@plt>
test   %eax,%eax
je     11d1 <getuint_or_obj+0x91>
lea    0xe70(%rip),%r12
mov    %r12,%rdi
call   1040 <strlen@plt>
mov    %r12,%rdi
mov    %r15,%rsi
mov    %eax,%edx
call   1030 <strncmp@plt>
test   %eax,%eax
je     11e9 <getuint_or_obj+0xa9>
lea    0xe54(%rip),%rdi
call   1050 <panic@plt>
mov    %r15,%rbx
jmp    11f4 <getuint_or_obj+0xb4>
mov    %rbx,%rdi
mov    %r12,%rsi
call   1060 <getuint@plt>
movl   $0x0,(%r14)
jmp    11f7 <getuint_or_obj+0xb7>
add    $0x3,%rbx
mov    %rbx,%rdi
mov    %r12,%rsi
call   1060 <getuint@plt>
movl   $0x1,(%r14)
jmp    11f7 <getuint_or_obj+0xb7>
movl   $0x2,(%r14)
add    $0x4,%rbx
mov    %rbx,%rax
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
ret

LLVM IR (-O0):
@.str = [3 x i8] c"II\00"
@.str.1 = [4 x i8] c"PRB\00"
@.str.2 = [15 x i8] c"Syntax error!\0A\00"
define i8* @getuint_or_obj(i8* %0, i32* %1, i32* %2) {
%4 = alloca i8*
%5 = alloca i32*
%6 = alloca i32*
store i8* %0, i8** %4
store i32* %1, i32** %5
store i32* %2, i32** %6
%7 = load i8*, i8** %4
%8 = load i8, i8* %7
%9 = sext i8 %8 to i32
%10 = icmp eq i32 %9, 10
br i1 %10, label %11, label %13
11: ; preds = %3
%12 = load i32*, i32** %6
store i32 3, i32* %12
br label %51
13: ; preds = %3
%14 = load i8*, i8** %4
%15 = load i8, i8* %14
%16 = sext i8 %15 to i32
%17 = icmp eq i32 %16, 36
br i1 %17, label %18, label %45
18: ; preds = %13
%19 = load i8*, i8** %4
%20 = getelementptr inbounds i8, i8* %19, i32 1
store i8* %20, i8** %4
%21 = load i8*, i8** %4
%22 = call i32 @strlen(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str, i64 0, i64 0))
%23 = call i32 @strncmp(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str, i64 0, i64 0), i8* %21, i32 %22)
%24 = icmp ne i32 %23, 0
br i1 %24, label %32, label %25
25: ; preds = %18
%26 = load i8*, i8** %4
%27 = getelementptr inbounds i8, i8* %26, i64 2
store i8* %27, i8** %4
%28 = load i8*, i8** %4
%29 = load i32*, i32** %5
%30 = call i8* @getuint(i8* %28, i32* %29)
store i8* %30, i8** %4
%31 = load i32*, i32** %6
store i32 1, i32* %31
br label %44
32: ; preds = %18
%33 = load i8*, i8** %4
%34 = call i32 @strlen(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.1, i64 0, i64 0))
%35 = call i32 @strncmp(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.1, i64 0, i64 0), i8* %33, i32 %34)
%36 = icmp ne i32 %35, 0
br i1 %36, label %41, label %37
37: ; preds = %32
%38 = load i32*, i32** %6
store i32 2, i32* %38
%39 = load i8*, i8** %4
%40 = getelementptr inbounds i8, i8* %39, i64 3
store i8* %40, i8** %4
br label %43
41: ; preds = %32
%42 = call i32 @panic(i8* getelementptr inbounds ([15 x i8], [15 x i8]* @.str.2, i64 0, i64 0))
br label %43
43: ; preds = %41, %37
br label %44
44: ; preds = %43, %25
br label %50
45: ; preds = %13
%46 = load i8*, i8** %4
%47 = load i32*, i32** %5
%48 = call i8* @getuint(i8* %46, i32* %47)
store i8* %48, i8** %4
%49 = load i32*, i32** %6
store i32 0, i32* %49
br label %50
50: ; preds = %45, %44
br label %51
51: ; preds = %50, %11
%52 = load i8*, i8** %4
ret i8* %52
}

LLVM IR (-O2):
@.str = [3 x i8] c"II\00"
@.str.1 = [4 x i8] c"PRB\00"
@.str.2 = [15 x i8] c"Syntax error!\0A\00"
define i8* @getuint_or_obj(i8* %0, i32* %1, i32* nocapture writeonly %2) {
%4 = load i8, i8* %0
switch i8 %4, label %22 [
i8 10, label %5
i8 36, label %6
]
5: ; preds = %3
store i32 3, i32* %2
br label %24
6: ; preds = %3
%7 = getelementptr inbounds i8, i8* %0, i64 1
%8 = tail call i32 @strlen(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str, i64 0, i64 0))
%9 = tail call i32 @strncmp(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str, i64 0, i64 0), i8* %7, i32 %8)
%10 = icmp eq i32 %9, 0
br i1 %10, label %11, label %14
11: ; preds = %6
%12 = getelementptr inbounds i8, i8* %0, i64 3
%13 = tail call i8* @getuint(i8* %12, i32* %1)
store i32 1, i32* %2
br label %24
14: ; preds = %6
%15 = tail call i32 @strlen(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.1, i64 0, i64 0))
%16 = tail call i32 @strncmp(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.1, i64 0, i64 0), i8* %7, i32 %15)
%17 = icmp eq i32 %16, 0
br i1 %17, label %18, label %20
18: ; preds = %14
store i32 2, i32* %2
%19 = getelementptr inbounds i8, i8* %0, i64 4
br label %24
20: ; preds = %14
%21 = tail call i32 @panic(i8* getelementptr inbounds ([15 x i8], [15 x i8]* @.str.2, i64 0, i64 0))
br label %24
22: ; preds = %3
%23 = tail call i8* @getuint(i8* %0, i32* %1)
store i32 0, i32* %2
br label %24
24: ; preds = %22, %18, %20, %11, %5
%25 = phi i8* [ %0, %5 ], [ %7, %20 ], [ %19, %18 ], [ %13, %11 ], [ %23, %22 ]
ret i8* %25
}