#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 atoi(char *);
int /*<<< orphan*/ *fgets(char *, int, int /*<<< orphan*/ *);
int /*<<< orphan*/ printf(char *, int, int, char);
int /*<<< orphan*/ strcmp(char *, char *);
int /*<<< orphan*/ strcpy(char *, char *);
char *strtok(char *, char *);
int get_format_line(FILE *format_file, int *type, int *array_size, char *name,
                    int *bit_size) {
  char line[40];
  char *var_type;
  if (fgets(line, 40, format_file) != NULL) {
    var_type = strtok(line, " ");
    if (!strcmp(var_type, "char")) {
      *type = 0;
      *bit_size = 1;
    } else if (!strcmp(var_type, "ushort")) {
      *type = 1;
      *bit_size = 2;
    } else if (!strcmp(var_type, "uint")) {
      *type = 2;
      *bit_size = 4;
    } else if (!strcmp(var_type, "ulong")) {
      *type = 3;
      *bit_size = 4;
    }
    *array_size = atoi(strtok(NULL, " "));
    strcpy(name, strtok(NULL, " "));
    if (0)
      printf("  Debug Format Line: type=%d, size=%d, name=%c\n", *type,
             *array_size, name[0]);
    return (1);
  } else
    return (0);
}


x86 assembly (clang, -O0):
<get_format_line>:
push   %rbp
mov    %rsp,%rbp
sub    $0x70,%rsp
mov    %rdi,-0x10(%rbp)
mov    %rsi,-0x18(%rbp)
mov    %rdx,-0x20(%rbp)
mov    %rcx,-0x28(%rbp)
mov    %r8,-0x30(%rbp)
lea    -0x60(%rbp),%rdi
mov    -0x10(%rbp),%rdx
mov    $0x28,%esi
call   1040 <fgets@plt>
cmp    $0x0,%rax
je     12be <get_format_line+0x16e>
lea    -0x60(%rbp),%rdi
lea    0xe6d(%rip),%rsi
call   1060 <strtok@plt>
mov    %rax,-0x68(%rbp)
mov    -0x68(%rbp),%rdi
lea    0xe5b(%rip),%rsi
call   1050 <strcmp@plt>
cmp    $0x0,%eax
jne    11ce <get_format_line+0x7e>
mov    -0x18(%rbp),%rax
movl   $0x0,(%rax)
mov    -0x30(%rbp),%rax
movl   $0x1,(%rax)
jmp    126e <get_format_line+0x11e>
mov    -0x68(%rbp),%rdi
lea    0xe2e(%rip),%rsi
call   1050 <strcmp@plt>
cmp    $0x0,%eax
jne    1200 <get_format_line+0xb0>
mov    -0x18(%rbp),%rax
movl   $0x1,(%rax)
mov    -0x30(%rbp),%rax
movl   $0x2,(%rax)
jmp    1269 <get_format_line+0x119>
mov    -0x68(%rbp),%rdi
lea    0xe03(%rip),%rsi
call   1050 <strcmp@plt>
cmp    $0x0,%eax
jne    1232 <get_format_line+0xe2>
mov    -0x18(%rbp),%rax
movl   $0x2,(%rax)
mov    -0x30(%rbp),%rax
movl   $0x4,(%rax)
jmp    1264 <get_format_line+0x114>
mov    -0x68(%rbp),%rdi
lea    0xdd6(%rip),%rsi
call   1050 <strcmp@plt>
cmp    $0x0,%eax
jne    125f <get_format_line+0x10f>
mov    -0x18(%rbp),%rax
movl   $0x3,(%rax)
mov    -0x30(%rbp),%rax
movl   $0x4,(%rax)
jmp    1264 <get_format_line+0x114>
jmp    1269 <get_format_line+0x119>
jmp    126e <get_format_line+0x11e>
xor    %eax,%eax
mov    %eax,%edi
lea    0xd87(%rip),%rsi
call   1060 <strtok@plt>
mov    %rax,%rdi
call   1070 <atoi@plt>
mov    %eax,%ecx
mov    -0x20(%rbp),%rax
mov    %ecx,(%rax)
mov    -0x28(%rbp),%rax
mov    %rax,-0x70(%rbp)
xor    %eax,%eax
mov    %eax,%edi
lea    0xd5f(%rip),%rsi
call   1060 <strtok@plt>
mov    -0x70(%rbp),%rdi
mov    %rax,%rsi
call   1030 <strcpy@plt>
movl   $0x1,-0x4(%rbp)
jmp    12c5 <get_format_line+0x175>
movl   $0x0,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x70,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<get_format_line>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
sub    $0x28,%rsp
mov    %r8,%r12
mov    %rcx,%r14
mov    %rdx,%r15
mov    %rsi,%r13
mov    %rdi,%rdx
mov    %rsp,%rdi
mov    $0x28,%esi
call   1040 <fgets@plt>
test   %rax,%rax
je     11e9 <get_format_line+0x99>
lea    0xe7a(%rip),%rsi
mov    %rsp,%rdi
call   1060 <strtok@plt>
mov    %rax,%rbx
lea    0xe6a(%rip),%rsi
mov    %rax,%rdi
call   1050 <strcmp@plt>
test   %eax,%eax
je     11ed <get_format_line+0x9d>
lea    0xe5c(%rip),%rsi
mov    %rbx,%rdi
call   1050 <strcmp@plt>
test   %eax,%eax
je     11f6 <get_format_line+0xa6>
lea    0xe50(%rip),%rsi
mov    %rbx,%rdi
call   1050 <strcmp@plt>
mov    $0x4,%ebp
test   %eax,%eax
je     1202 <get_format_line+0xb2>
lea    0xe3d(%rip),%rsi
mov    %rbx,%rdi
call   1050 <strcmp@plt>
test   %eax,%eax
jne    120f <get_format_line+0xbf>
mov    $0x3,%eax
jmp    1207 <get_format_line+0xb7>
xor    %eax,%eax
jmp    1245 <get_format_line+0xf5>
mov    $0x1,%ebp
xor    %eax,%eax
jmp    1207 <get_format_line+0xb7>
mov    $0x2,%ebp
mov    $0x1,%eax
jmp    1207 <get_format_line+0xb7>
mov    $0x2,%eax
mov    %eax,0x0(%r13)
mov    %ebp,(%r12)
lea    0xdea(%rip),%rbx
xor    %edi,%edi
mov    %rbx,%rsi
call   1060 <strtok@plt>
mov    %rax,%rdi
call   1070 <atoi@plt>
mov    %eax,(%r15)
xor    %edi,%edi
mov    %rbx,%rsi
call   1060 <strtok@plt>
mov    %r14,%rdi
mov    %rax,%rsi
call   1030 <strcpy@plt>
mov    $0x1,%eax
add    $0x28,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
@.str = [2 x i8] c" \00"
@.str.1 = [5 x i8] c"char\00"
@.str.2 = [7 x i8] c"ushort\00"
@.str.3 = [5 x i8] c"uint\00"
@.str.4 = [6 x i8] c"ulong\00"
define i32 @get_format_line(i32* %0, i32* %1, i32* %2, i8* %3, i32* %4) {
%6 = alloca i32
%7 = alloca i32*
%8 = alloca i32*
%9 = alloca i32*
%10 = alloca i8*
%11 = alloca i32*
%12 = alloca [40 x i8]
%13 = alloca i8*
store i32* %0, i32** %7
store i32* %1, i32** %8
store i32* %2, i32** %9
store i8* %3, i8** %10
store i32* %4, i32** %11
%14 = getelementptr inbounds [40 x i8], [40 x i8]* %12, i64 0, i64 0
%15 = load i32*, i32** %7
%16 = call i32* @fgets(i8* %14, i32 40, i32* %15)
%17 = icmp ne i32* %16, null
br i1 %17, label %18, label %58
18: ; preds = %5
%19 = getelementptr inbounds [40 x i8], [40 x i8]* %12, i64 0, i64 0
%20 = call i8* @strtok(i8* %19, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str, i64 0, i64 0))
store i8* %20, i8** %13
%21 = load i8*, i8** %13
%22 = call i32 @strcmp(i8* %21, i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.1, i64 0, i64 0))
%23 = icmp ne i32 %22, 0
br i1 %23, label %27, label %24
24: ; preds = %18
%25 = load i32*, i32** %8
store i32 0, i32* %25
%26 = load i32*, i32** %11
store i32 1, i32* %26
br label %51
27: ; preds = %18
%28 = load i8*, i8** %13
%29 = call i32 @strcmp(i8* %28, i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str.2, i64 0, i64 0))
%30 = icmp ne i32 %29, 0
br i1 %30, label %34, label %31
31: ; preds = %27
%32 = load i32*, i32** %8
store i32 1, i32* %32
%33 = load i32*, i32** %11
store i32 2, i32* %33
br label %50
34: ; preds = %27
%35 = load i8*, i8** %13
%36 = call i32 @strcmp(i8* %35, i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.3, i64 0, i64 0))
%37 = icmp ne i32 %36, 0
br i1 %37, label %41, label %38
38: ; preds = %34
%39 = load i32*, i32** %8
store i32 2, i32* %39
%40 = load i32*, i32** %11
store i32 4, i32* %40
br label %49
41: ; preds = %34
%42 = load i8*, i8** %13
%43 = call i32 @strcmp(i8* %42, i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.4, i64 0, i64 0))
%44 = icmp ne i32 %43, 0
br i1 %44, label %48, label %45
45: ; preds = %41
%46 = load i32*, i32** %8
store i32 3, i32* %46
%47 = load i32*, i32** %11
store i32 4, i32* %47
br label %48
48: ; preds = %45, %41
br label %49
49: ; preds = %48, %38
br label %50
50: ; preds = %49, %31
br label %51
51: ; preds = %50, %24
%52 = call i8* @strtok(i8* null, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str, i64 0, i64 0))
%53 = call i32 @atoi(i8* %52)
%54 = load i32*, i32** %9
store i32 %53, i32* %54
%55 = load i8*, i8** %10
%56 = call i8* @strtok(i8* null, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str, i64 0, i64 0))
%57 = call i32 @strcpy(i8* %55, i8* %56)
store i32 1, i32* %6
br label %59
58: ; preds = %5
store i32 0, i32* %6
br label %59
59: ; preds = %58, %51
%60 = load i32, i32* %6
ret i32 %60
}

LLVM IR (-O2):
@.str = [2 x i8] c" \00"
@.str.1 = [5 x i8] c"char\00"
@.str.2 = [7 x i8] c"ushort\00"
@.str.3 = [5 x i8] c"uint\00"
@.str.4 = [6 x i8] c"ulong\00"
define i32 @get_format_line(i32* nocapture %0, i32* nocapture writeonly %1, i32* nocapture writeonly %2, i8* %3, i32* nocapture writeonly %4) {
%6 = alloca [40 x i8]
%7 = getelementptr inbounds [40 x i8], [40 x i8]* %6, i64 0, i64 0
%8 = call i32* @fgets(i8* %7, i32 40, i32* %0)
%9 = icmp eq i32* %8, null
br i1 %9, label %31, label %10
10: ; preds = %5
%11 = call i8* @strtok(i8* %7, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str, i64 0, i64 0))
%12 = call i32 @strcmp(i8* dereferenceable(1) %11, i8* dereferenceable(5) getelementptr inbounds ([5 x i8], [5 x i8]* @.str.1, i64 0, i64 0))
%13 = icmp eq i32 %12, 0
br i1 %13, label %23, label %14
14: ; preds = %10
%15 = call i32 @strcmp(i8* dereferenceable(1) %11, i8* dereferenceable(7) getelementptr inbounds ([7 x i8], [7 x i8]* @.str.2, i64 0, i64 0))
%16 = icmp eq i32 %15, 0
br i1 %16, label %23, label %17
17: ; preds = %14
%18 = call i32 @strcmp(i8* dereferenceable(1) %11, i8* dereferenceable(5) getelementptr inbounds ([5 x i8], [5 x i8]* @.str.3, i64 0, i64 0))
%19 = icmp eq i32 %18, 0
br i1 %19, label %23, label %20
20: ; preds = %17
%21 = call i32 @strcmp(i8* dereferenceable(1) %11, i8* dereferenceable(6) getelementptr inbounds ([6 x i8], [6 x i8]* @.str.4, i64 0, i64 0))
%22 = icmp eq i32 %21, 0
br i1 %22, label %23, label %26
23: ; preds = %20, %17, %14, %10
%24 = phi i32 [ 0, %10 ], [ 1, %14 ], [ 2, %17 ], [ 3, %20 ]
%25 = phi i32 [ 1, %10 ], [ 2, %14 ], [ 4, %17 ], [ 4, %20 ]
store i32 %24, i32* %1
store i32 %25, i32* %4
br label %26
26: ; preds = %23, %20
%27 = call i8* @strtok(i8* null, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str, i64 0, i64 0))
%28 = call i32 @atoi(i8* %27)
store i32 %28, i32* %2
%29 = call i8* @strtok(i8* null, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str, i64 0, i64 0))
%30 = call i32 @strcpy(i8* %3, i8* %29)
br label %31
31: ; preds = %5, %26
%32 = phi i32 [ 1, %26 ], [ 0, %5 ]
ret i32 %32
}