#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 EOF;
int fgetc(int /*<<< orphan*/ *);
int getUInt(int /*<<< orphan*/ *);
int /*<<< orphan*/ skipLine(int /*<<< orphan*/ *);
int getVoiceNum(FILE *fp) {
  int c;
  while (1) {
    c = fgetc(fp);
    if (c == EOF)
      return -1;
    if (c == '#')
      skipLine(fp);
    if (c == '(')
      break;
  }
  while (1) {
    c = fgetc(fp);
    if (c == EOF)
      return -1;
    if (c == '#')
      skipLine(fp);
    if (c == '@')
      break;
  }
  c = getUInt(fp);
  if (c < 0)
    return -1;
  return c;
}


x86 assembly (clang, -O0):
<getVoiceNum>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %rdi,-0x10(%rbp)
mov    -0x10(%rbp),%rdi
call   1040 <fgetc@plt>
mov    %eax,-0x14(%rbp)
mov    -0x14(%rbp),%eax
mov    0x2e96(%rip),%rcx
cmp    (%rcx),%eax
jne    1166 <getVoiceNum+0x36>
movl   $0xffffffff,-0x4(%rbp)
jmp    120b <getVoiceNum+0xdb>
cmpl   $0x23,-0x14(%rbp)
jne    1179 <getVoiceNum+0x49>
mov    -0x10(%rbp),%rdi
call   1030 <skipLine@plt>
cmpl   $0x28,-0x14(%rbp)
jne    1188 <getVoiceNum+0x58>
jmp    118d <getVoiceNum+0x5d>
jmp    113c <getVoiceNum+0xc>
jmp    1192 <getVoiceNum+0x62>
mov    -0x10(%rbp),%rdi
call   1040 <fgetc@plt>
mov    %eax,-0x14(%rbp)
mov    -0x14(%rbp),%eax
mov    0x2e40(%rip),%rcx
cmp    (%rcx),%eax
jne    11bc <getVoiceNum+0x8c>
movl   $0xffffffff,-0x4(%rbp)
jmp    120b <getVoiceNum+0xdb>
cmpl   $0x23,-0x14(%rbp)
jne    11cf <getVoiceNum+0x9f>
mov    -0x10(%rbp),%rdi
call   1030 <skipLine@plt>
cmpl   $0x40,-0x14(%rbp)
jne    11de <getVoiceNum+0xae>
jmp    11e3 <getVoiceNum+0xb3>
jmp    1192 <getVoiceNum+0x62>
mov    -0x10(%rbp),%rdi
call   1050 <getUInt@plt>
mov    %eax,-0x14(%rbp)
cmpl   $0x0,-0x14(%rbp)
jge    1205 <getVoiceNum+0xd5>
movl   $0xffffffff,-0x4(%rbp)
jmp    120b <getVoiceNum+0xdb>
mov    -0x14(%rbp),%eax
mov    %eax,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<getVoiceNum>:
push   %rbp
push   %r14
push   %rbx
mov    %rdi,%rbx
call   1040 <fgetc@plt>
mov    0x2ea5(%rip),%rbp
mov    $0xffffffff,%r14d
jmp    1160 <getVoiceNum+0x30>
nopl   0x0(%rax,%rax,1)
mov    %rbx,%rdi
call   1030 <skipLine@plt>
mov    %rbx,%rdi
call   1040 <fgetc@plt>
cmp    0x0(%rbp),%eax
je     11b3 <getVoiceNum+0x83>
cmp    $0x23,%eax
je     1150 <getVoiceNum+0x20>
cmp    $0x28,%eax
jne    1158 <getVoiceNum+0x28>
jmp    1188 <getVoiceNum+0x58>
cs nopw 0x0(%rax,%rax,1)
nopl   0x0(%rax,%rax,1)
mov    %rbx,%rdi
call   1030 <skipLine@plt>
mov    %rbx,%rdi
call   1040 <fgetc@plt>
cmp    0x0(%rbp),%eax
je     11b3 <getVoiceNum+0x83>
cmp    $0x23,%eax
je     1180 <getVoiceNum+0x50>
cmp    $0x40,%eax
jne    1188 <getVoiceNum+0x58>
mov    %rbx,%rdi
call   1050 <getUInt@plt>
test   %eax,%eax
mov    $0xffffffff,%r14d
cmovns %eax,%r14d
mov    %r14d,%eax
pop    %rbx
pop    %r14
pop    %rbp
ret

LLVM IR (-O0):
@EOF = global i32 0
define i32 @getVoiceNum(i32* %0) {
%2 = alloca i32
%3 = alloca i32*
%4 = alloca i32
store i32* %0, i32** %3
br label %5
5: ; preds = %1, %22
%6 = load i32*, i32** %3
%7 = call i32 @fgetc(i32* %6)
store i32 %7, i32* %4
%8 = load i32, i32* %4
%9 = load i32, i32* @EOF
%10 = icmp eq i32 %8, %9
br i1 %10, label %11, label %12
11: ; preds = %5
store i32 -1, i32* %2
br label %50
12: ; preds = %5
%13 = load i32, i32* %4
%14 = icmp eq i32 %13, 35
br i1 %14, label %15, label %18
15: ; preds = %12
%16 = load i32*, i32** %3
%17 = call i32 @skipLine(i32* %16)
br label %18
18: ; preds = %15, %12
%19 = load i32, i32* %4
%20 = icmp eq i32 %19, 40
br i1 %20, label %21, label %22
21: ; preds = %18
br label %23
22: ; preds = %18
br label %5
23: ; preds = %21
br label %24
24: ; preds = %23, %41
%25 = load i32*, i32** %3
%26 = call i32 @fgetc(i32* %25)
store i32 %26, i32* %4
%27 = load i32, i32* %4
%28 = load i32, i32* @EOF
%29 = icmp eq i32 %27, %28
br i1 %29, label %30, label %31
30: ; preds = %24
store i32 -1, i32* %2
br label %50
31: ; preds = %24
%32 = load i32, i32* %4
%33 = icmp eq i32 %32, 35
br i1 %33, label %34, label %37
34: ; preds = %31
%35 = load i32*, i32** %3
%36 = call i32 @skipLine(i32* %35)
br label %37
37: ; preds = %34, %31
%38 = load i32, i32* %4
%39 = icmp eq i32 %38, 64
br i1 %39, label %40, label %41
40: ; preds = %37
br label %42
41: ; preds = %37
br label %24
42: ; preds = %40
%43 = load i32*, i32** %3
%44 = call i32 @getUInt(i32* %43)
store i32 %44, i32* %4
%45 = load i32, i32* %4
%46 = icmp slt i32 %45, 0
br i1 %46, label %47, label %48
47: ; preds = %42
store i32 -1, i32* %2
br label %50
48: ; preds = %42
%49 = load i32, i32* %4
store i32 %49, i32* %2
br label %50
50: ; preds = %48, %47, %30, %11
%51 = load i32, i32* %2
ret i32 %51
}

LLVM IR (-O2):
@EOF = global i32 0
define i32 @getVoiceNum(i32* %0) {
%2 = tail call i32 @fgetc(i32* %0)
%3 = load i32, i32* @EOF
%4 = icmp eq i32 %2, %3
br i1 %4, label %29, label %5
5: ; preds = %1, %7
%6 = phi i32 [ %8, %7 ], [ %2, %1 ]
switch i32 %6, label %7 [
i32 35, label %15
i32 40, label %11
]
7: ; preds = %5, %15
%8 = tail call i32 @fgetc(i32* %0)
%9 = load i32, i32* @EOF
%10 = icmp eq i32 %8, %9
br i1 %10, label %29, label %5
11: ; preds = %5
%12 = tail call i32 @fgetc(i32* %0)
%13 = load i32, i32* @EOF
%14 = icmp eq i32 %12, %13
br i1 %14, label %29, label %17
15: ; preds = %5
%16 = tail call i32 @skipLine(i32* %0)
br label %7
17: ; preds = %11, %19
%18 = phi i32 [ %20, %19 ], [ %12, %11 ]
switch i32 %18, label %19 [
i32 35, label %23
i32 64, label %25
]
19: ; preds = %17, %23
%20 = tail call i32 @fgetc(i32* %0)
%21 = load i32, i32* @EOF
%22 = icmp eq i32 %20, %21
br i1 %22, label %29, label %17
23: ; preds = %17
%24 = tail call i32 @skipLine(i32* %0)
br label %19
25: ; preds = %17
%26 = tail call i32 @getUInt(i32* %0)
%27 = icmp sgt i32 %26, -1
%28 = select i1 %27, i32 %26, i32 -1
br label %29
29: ; preds = %7, %19, %1, %11, %25
%30 = phi i32 [ %28, %25 ], [ -1, %11 ], [ -1, %1 ], [ -1, %19 ], [ -1, %7 ]
ret i32 %30
}