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

/* Variables and functions */
scalar_t__ fgets(char *, int, int /*<<< orphan*/ *);
int sscanf(char *, char *, int *, ...);
int /*<<< orphan*/ strcpy(char *, char *);
int read_id_name(FILE *fp, int *id, char *name) {
  char buf[512];
  int min, maj;
  while (fgets(buf, sizeof(buf), fp)) {
    char *p = buf;
    while (*p == ' ' || *p == '\t')
      p++;
    if (*p == '#' || *p == '\n' || *p == 0)
      continue;
    if (sscanf(p, "%x:%x %s\n", &maj, &min, name) == 3) {
      *id = (maj << 16) | min;
    } else if (sscanf(p, "%x:%x %s #", &maj, &min, name) == 3) {
      *id = (maj << 16) | min;
    } else if (sscanf(p, "0x%x %s\n", id, name) != 2 &&
               sscanf(p, "0x%x %s #", id, name) != 2 &&
               sscanf(p, "%d %s\n", id, name) != 2 &&
               sscanf(p, "%d %s #", id, name) != 2) {
      strcpy(name, p);
      return -1;
    }
    return 1;
  }
  return 0;
}


x86 assembly (clang, -O0):
<read_id_name>:
push   %rbp
mov    %rsp,%rbp
sub    $0x240,%rsp
mov    %rdi,-0x10(%rbp)
mov    %rsi,-0x18(%rbp)
mov    %rdx,-0x20(%rbp)
lea    -0x220(%rbp),%rdi
mov    -0x10(%rbp),%rdx
mov    $0x200,%esi
call   1040 <fgets@plt>
cmp    $0x0,%rax
je     136b <read_id_name+0x23b>
lea    -0x220(%rbp),%rax
mov    %rax,-0x230(%rbp)
mov    -0x230(%rbp),%rax
movsbl (%rax),%ecx
mov    $0x1,%al
cmp    $0x20,%ecx
mov    %al,-0x231(%rbp)
je     11a5 <read_id_name+0x75>
mov    -0x230(%rbp),%rax
movsbl (%rax),%eax
cmp    $0x9,%eax
sete   %al
mov    %al,-0x231(%rbp)
mov    -0x231(%rbp),%al
test   $0x1,%al
jne    11b8 <read_id_name+0x88>
jmp    11cf <read_id_name+0x9f>
mov    -0x230(%rbp),%rax
add    $0x1,%rax
mov    %rax,-0x230(%rbp)
jmp    1174 <read_id_name+0x44>
mov    -0x230(%rbp),%rax
movsbl (%rax),%eax
cmp    $0x23,%eax
je     1208 <read_id_name+0xd8>
mov    -0x230(%rbp),%rax
movsbl (%rax),%eax
cmp    $0xa,%eax
je     1208 <read_id_name+0xd8>
mov    -0x230(%rbp),%rax
movsbl (%rax),%eax
cmp    $0x0,%eax
jne    120d <read_id_name+0xdd>
jmp    1147 <read_id_name+0x17>
mov    -0x230(%rbp),%rdi
mov    -0x20(%rbp),%r8
lea    0xde1(%rip),%rsi
lea    -0x228(%rbp),%rdx
lea    -0x224(%rbp),%rcx
mov    $0x0,%al
call   1050 <sscanf@plt>
cmp    $0x3,%eax
jne    1257 <read_id_name+0x127>
mov    -0x228(%rbp),%ecx
shl    $0x10,%ecx
or     -0x224(%rbp),%ecx
mov    -0x18(%rbp),%rax
mov    %ecx,(%rax)
jmp    135f <read_id_name+0x22f>
mov    -0x230(%rbp),%rdi
mov    -0x20(%rbp),%r8
lea    0xda1(%rip),%rsi
lea    -0x228(%rbp),%rdx
lea    -0x224(%rbp),%rcx
mov    $0x0,%al
call   1050 <sscanf@plt>
cmp    $0x3,%eax
jne    12a1 <read_id_name+0x171>
mov    -0x228(%rbp),%ecx
shl    $0x10,%ecx
or     -0x224(%rbp),%ecx
mov    -0x18(%rbp),%rax
mov    %ecx,(%rax)
jmp    135a <read_id_name+0x22a>
mov    -0x230(%rbp),%rdi
mov    -0x18(%rbp),%rdx
mov    -0x20(%rbp),%rcx
lea    0xd5e(%rip),%rsi
mov    $0x0,%al
call   1050 <sscanf@plt>
cmp    $0x2,%eax
je     1355 <read_id_name+0x225>
mov    -0x230(%rbp),%rdi
mov    -0x18(%rbp),%rdx
mov    -0x20(%rbp),%rcx
lea    0xd41(%rip),%rsi
mov    $0x0,%al
call   1050 <sscanf@plt>
cmp    $0x2,%eax
je     1355 <read_id_name+0x225>
mov    -0x230(%rbp),%rdi
mov    -0x18(%rbp),%rdx
mov    -0x20(%rbp),%rcx
lea    0xd25(%rip),%rsi
mov    $0x0,%al
call   1050 <sscanf@plt>
cmp    $0x2,%eax
je     1355 <read_id_name+0x225>
mov    -0x230(%rbp),%rdi
mov    -0x18(%rbp),%rdx
mov    -0x20(%rbp),%rcx
lea    0xd06(%rip),%rsi
mov    $0x0,%al
call   1050 <sscanf@plt>
cmp    $0x2,%eax
je     1355 <read_id_name+0x225>
mov    -0x20(%rbp),%rdi
mov    -0x230(%rbp),%rsi
call   1030 <strcpy@plt>
movl   $0xffffffff,-0x4(%rbp)
jmp    1372 <read_id_name+0x242>
jmp    135a <read_id_name+0x22a>
jmp    135f <read_id_name+0x22f>
movl   $0x1,-0x4(%rbp)
jmp    1372 <read_id_name+0x242>
movl   $0x0,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x240,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<read_id_name>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
sub    $0x228,%rsp
mov    %rdx,%r14
mov    %rsi,%rbx
mov    %rdi,%rbp
lea    0x20(%rsp),%r13
mov    %r13,%rdi
mov    $0x200,%esi
mov    %rbp,%rdx
call   1040 <fgets@plt>
xor    %r12d,%r12d
test   %rax,%rax
je     1226 <read_id_name+0xf6>
mov    %rbx,0x10(%rsp)
mov    %r14,0x18(%rsp)
movabs $0x800000401,%r14
movabs $0x100000200,%r15
mov    %r13,%rbx
jmp    11a8 <read_id_name+0x78>
xchg   %ax,%ax
mov    %r13,%rdi
mov    $0x200,%esi
mov    %rbp,%rdx
call   1040 <fgets@plt>
mov    %r13,%rbx
test   %rax,%rax
je     1226 <read_id_name+0xf6>
movzbl (%rbx),%eax
cmp    $0x23,%rax
ja     11c3 <read_id_name+0x93>
bt     %rax,%r14
jb     1190 <read_id_name+0x60>
bt     %rax,%r15
jae    11c3 <read_id_name+0x93>
add    $0x1,%rbx
jmp    11a8 <read_id_name+0x78>
lea    0xe36(%rip),%rsi
lea    0x8(%rsp),%rdx
lea    0xc(%rsp),%rcx
mov    %rbx,%rdi
mov    0x18(%rsp),%rbp
mov    %rbp,%r8
xor    %eax,%eax
call   1050 <sscanf@plt>
cmp    $0x3,%eax
je     120e <read_id_name+0xde>
lea    0xe18(%rip),%rsi
lea    0x8(%rsp),%rdx
lea    0xc(%rsp),%rcx
mov    %rbx,%rdi
mov    %rbp,%r8
xor    %eax,%eax
call   1050 <sscanf@plt>
cmp    $0x3,%eax
jne    123b <read_id_name+0x10b>
mov    0x8(%rsp),%eax
shl    $0x10,%eax
or     0xc(%rsp),%eax
mov    0x10(%rsp),%rcx
mov    %eax,(%rcx)
mov    $0x1,%r12d
mov    %r12d,%eax
add    $0x228,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret
lea    0xdd3(%rip),%rsi
mov    %rbx,%rdi
mov    0x10(%rsp),%r14
mov    %r14,%rdx
mov    %rbp,%rcx
xor    %eax,%eax
call   1050 <sscanf@plt>
mov    $0x1,%r12d
cmp    $0x2,%eax
je     1226 <read_id_name+0xf6>
lea    0xdb5(%rip),%rsi
mov    %rbx,%rdi
mov    %r14,%rdx
mov    %rbp,%rcx
xor    %eax,%eax
call   1050 <sscanf@plt>
cmp    $0x2,%eax
je     1226 <read_id_name+0xf6>
lea    0xda3(%rip),%rsi
mov    %rbx,%rdi
mov    %r14,%rdx
mov    %rbp,%rcx
xor    %eax,%eax
call   1050 <sscanf@plt>
cmp    $0x2,%eax
je     1226 <read_id_name+0xf6>
lea    0xd8e(%rip),%rsi
mov    %rbx,%rdi
mov    %r14,%rdx
mov    %rbp,%rcx
xor    %eax,%eax
call   1050 <sscanf@plt>
cmp    $0x2,%eax
je     1226 <read_id_name+0xf6>
mov    %rbp,%rdi
mov    %rbx,%rsi
call   1030 <strcpy@plt>
mov    $0xffffffff,%r12d
jmp    1226 <read_id_name+0xf6>

LLVM IR (-O0):
@.str = [10 x i8] c"%x:%x %s\0A\00"
@.str.1 = [11 x i8] c"%x:%x %s #\00"
@.str.2 = [9 x i8] c"0x%x %s\0A\00"
@.str.3 = [10 x i8] c"0x%x %s #\00"
@.str.4 = [7 x i8] c"%d %s\0A\00"
@.str.5 = [8 x i8] c"%d %s #\00"
define i32 @read_id_name(i32* %0, i32* %1, i8* %2) {
%4 = alloca i32
%5 = alloca i32*
%6 = alloca i32*
%7 = alloca i8*
%8 = alloca [512 x i8]
%9 = alloca i32
%10 = alloca i32
%11 = alloca i8*
store i32* %0, i32** %5
store i32* %1, i32** %6
store i8* %2, i8** %7
br label %12
12: ; preds = %49, %3
%13 = getelementptr inbounds [512 x i8], [512 x i8]* %8, i64 0, i64 0
%14 = load i32*, i32** %5
%15 = call i64 @fgets(i8* %13, i32 512, i32* %14)
%16 = icmp ne i64 %15, 0
br i1 %16, label %17, label %103
17: ; preds = %12
%18 = getelementptr inbounds [512 x i8], [512 x i8]* %8, i64 0, i64 0
store i8* %18, i8** %11
br label %19
19: ; preds = %31, %17
%20 = load i8*, i8** %11
%21 = load i8, i8* %20
%22 = sext i8 %21 to i32
%23 = icmp eq i32 %22, 32
br i1 %23, label %29, label %24
24: ; preds = %19
%25 = load i8*, i8** %11
%26 = load i8, i8* %25
%27 = sext i8 %26 to i32
%28 = icmp eq i32 %27, 9
br label %29
29: ; preds = %24, %19
%30 = phi i1 [ true, %19 ], [ %28, %24 ]
br i1 %30, label %31, label %34
31: ; preds = %29
%32 = load i8*, i8** %11
%33 = getelementptr inbounds i8, i8* %32, i32 1
store i8* %33, i8** %11
br label %19
34: ; preds = %29
%35 = load i8*, i8** %11
%36 = load i8, i8* %35
%37 = sext i8 %36 to i32
%38 = icmp eq i32 %37, 35
br i1 %38, label %49, label %39
39: ; preds = %34
%40 = load i8*, i8** %11
%41 = load i8, i8* %40
%42 = sext i8 %41 to i32
%43 = icmp eq i32 %42, 10
br i1 %43, label %49, label %44
44: ; preds = %39
%45 = load i8*, i8** %11
%46 = load i8, i8* %45
%47 = sext i8 %46 to i32
%48 = icmp eq i32 %47, 0
br i1 %48, label %49, label %50
49: ; preds = %44, %39, %34
br label %12
50: ; preds = %44
%51 = load i8*, i8** %11
%52 = load i8*, i8** %7
%53 = call i32 (i8*, i8*, i32*, ...) @sscanf(i8* %51, i8* getelementptr inbounds ([10 x i8], [10 x i8]* @.str, i64 0, i64 0), i32* %10, i32* %9, i8* %52)
%54 = icmp eq i32 %53, 3
br i1 %54, label %55, label %61
55: ; preds = %50
%56 = load i32, i32* %10
%57 = shl i32 %56, 16
%58 = load i32, i32* %9
%59 = or i32 %57, %58
%60 = load i32*, i32** %6
store i32 %59, i32* %60
br label %102
61: ; preds = %50
%62 = load i8*, i8** %11
%63 = load i8*, i8** %7
%64 = call i32 (i8*, i8*, i32*, ...) @sscanf(i8* %62, i8* getelementptr inbounds ([11 x i8], [11 x i8]* @.str.1, i64 0, i64 0), i32* %10, i32* %9, i8* %63)
%65 = icmp eq i32 %64, 3
br i1 %65, label %66, label %72
66: ; preds = %61
%67 = load i32, i32* %10
%68 = shl i32 %67, 16
%69 = load i32, i32* %9
%70 = or i32 %68, %69
%71 = load i32*, i32** %6
store i32 %70, i32* %71
br label %101
72: ; preds = %61
%73 = load i8*, i8** %11
%74 = load i32*, i32** %6
%75 = load i8*, i8** %7
%76 = call i32 (i8*, i8*, i32*, ...) @sscanf(i8* %73, i8* getelementptr inbounds ([9 x i8], [9 x i8]* @.str.2, i64 0, i64 0), i32* %74, i8* %75)
%77 = icmp ne i32 %76, 2
br i1 %77, label %78, label %100
78: ; preds = %72
%79 = load i8*, i8** %11
%80 = load i32*, i32** %6
%81 = load i8*, i8** %7
%82 = call i32 (i8*, i8*, i32*, ...) @sscanf(i8* %79, i8* getelementptr inbounds ([10 x i8], [10 x i8]* @.str.3, i64 0, i64 0), i32* %80, i8* %81)
%83 = icmp ne i32 %82, 2
br i1 %83, label %84, label %100
84: ; preds = %78
%85 = load i8*, i8** %11
%86 = load i32*, i32** %6
%87 = load i8*, i8** %7
%88 = call i32 (i8*, i8*, i32*, ...) @sscanf(i8* %85, i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str.4, i64 0, i64 0), i32* %86, i8* %87)
%89 = icmp ne i32 %88, 2
br i1 %89, label %90, label %100
90: ; preds = %84
%91 = load i8*, i8** %11
%92 = load i32*, i32** %6
%93 = load i8*, i8** %7
%94 = call i32 (i8*, i8*, i32*, ...) @sscanf(i8* %91, i8* getelementptr inbounds ([8 x i8], [8 x i8]* @.str.5, i64 0, i64 0), i32* %92, i8* %93)
%95 = icmp ne i32 %94, 2
br i1 %95, label %96, label %100
96: ; preds = %90
%97 = load i8*, i8** %7
%98 = load i8*, i8** %11
%99 = call i32 @strcpy(i8* %97, i8* %98)
store i32 -1, i32* %4
br label %104
100: ; preds = %90, %84, %78, %72
br label %101
101: ; preds = %100, %66
br label %102
102: ; preds = %101, %55
store i32 1, i32* %4
br label %104
103: ; preds = %12
store i32 0, i32* %4
br label %104
104: ; preds = %103, %102, %96
%105 = load i32, i32* %4
ret i32 %105
}

LLVM IR (-O2):
@.str = [10 x i8] c"%x:%x %s\0A\00"
@.str.1 = [11 x i8] c"%x:%x %s #\00"
@.str.2 = [9 x i8] c"0x%x %s\0A\00"
@.str.3 = [10 x i8] c"0x%x %s #\00"
@.str.4 = [7 x i8] c"%d %s\0A\00"
@.str.5 = [8 x i8] c"%d %s #\00"
define i32 @read_id_name(i32* nocapture %0, i32* %1, i8* %2) {
%4 = alloca [512 x i8]
%5 = alloca i32
%6 = alloca i32
%7 = getelementptr inbounds [512 x i8], [512 x i8]* %4, i64 0, i64 0
%8 = bitcast i32* %5 to i8*
%9 = bitcast i32* %6 to i8*
%10 = call i64 @fgets(i8* %7, i32 512, i32* %0)
%11 = icmp eq i64 %10, 0
br i1 %11, label %52, label %12
12: ; preds = %3, %17
%13 = phi i8* [ %18, %17 ], [ %7, %3 ]
%14 = load i8, i8* %13
switch i8 %14, label %19 [
i8 32, label %15
i8 9, label %15
i8 35, label %49
i8 10, label %49
i8 0, label %49
]
15: ; preds = %12, %12
%16 = getelementptr inbounds i8, i8* %13, i64 1
br label %17
17: ; preds = %15, %49
%18 = phi i8* [ %16, %15 ], [ %7, %49 ]
br label %12
19: ; preds = %12
%20 = call i32 (i8*, i8*, i32*, ...) @sscanf(i8* %13, i8* getelementptr inbounds ([10 x i8], [10 x i8]* @.str, i64 0, i64 0), i32* %6, i32* %5, i8* %2)
%21 = icmp eq i32 %20, 3
br i1 %21, label %22, label %27
22: ; preds = %19
%23 = load i32, i32* %6
%24 = shl i32 %23, 16
%25 = load i32, i32* %5
%26 = or i32 %24, %25
store i32 %26, i32* %1
br label %52
27: ; preds = %19
%28 = call i32 (i8*, i8*, i32*, ...) @sscanf(i8* %13, i8* getelementptr inbounds ([11 x i8], [11 x i8]* @.str.1, i64 0, i64 0), i32* %6, i32* %5, i8* %2)
%29 = icmp eq i32 %28, 3
br i1 %29, label %30, label %35
30: ; preds = %27
%31 = load i32, i32* %6
%32 = shl i32 %31, 16
%33 = load i32, i32* %5
%34 = or i32 %32, %33
store i32 %34, i32* %1
br label %52
35: ; preds = %27
%36 = call i32 (i8*, i8*, i32*, ...) @sscanf(i8* %13, i8* getelementptr inbounds ([9 x i8], [9 x i8]* @.str.2, i64 0, i64 0), i32* %1, i8* %2)
%37 = icmp eq i32 %36, 2
br i1 %37, label %52, label %38
38: ; preds = %35
%39 = call i32 (i8*, i8*, i32*, ...) @sscanf(i8* %13, i8* getelementptr inbounds ([10 x i8], [10 x i8]* @.str.3, i64 0, i64 0), i32* %1, i8* %2)
%40 = icmp eq i32 %39, 2
br i1 %40, label %52, label %41
41: ; preds = %38
%42 = call i32 (i8*, i8*, i32*, ...) @sscanf(i8* %13, i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str.4, i64 0, i64 0), i32* %1, i8* %2)
%43 = icmp eq i32 %42, 2
br i1 %43, label %52, label %44
44: ; preds = %41
%45 = call i32 (i8*, i8*, i32*, ...) @sscanf(i8* %13, i8* getelementptr inbounds ([8 x i8], [8 x i8]* @.str.5, i64 0, i64 0), i32* %1, i8* %2)
%46 = icmp eq i32 %45, 2
br i1 %46, label %52, label %47
47: ; preds = %44
%48 = call i32 @strcpy(i8* %2, i8* %13)
br label %52
49: ; preds = %12, %12, %12
%50 = call i64 @fgets(i8* %7, i32 512, i32* %0)
%51 = icmp eq i64 %50, 0
br i1 %51, label %52, label %17
52: ; preds = %49, %3, %22, %35, %38, %41, %44, %30, %47
%53 = phi i32 [ 1, %22 ], [ 1, %35 ], [ 1, %38 ], [ 1, %41 ], [ 1, %44 ], [ 1, %30 ], [ -1, %47 ], [ 0, %3 ], [ 0, %49 ]
ret i32 %53
}