#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*/ SEEK_CUR;
unsigned short atoi(char *);
int /*<<< orphan*/ exit(int);
int /*<<< orphan*/ fread(char **, int, int, int /*<<< orphan*/ *);
int /*<<< orphan*/ fseek(int /*<<< orphan*/ *, int, int /*<<< orphan*/);
int /*<<< orphan*/ printf(char *);
unsigned short read_number(FILE *file) {
  char str[4 + 1];
  fread(&str, 1, 4, file);
  str[4] = '\0';
  for (int i = 0; i < 4; i++) {
    if (str[i] < '0' || str[i] > '9') {
      if (i < 4 && str[i] == ':') {
        printf("Warning: Parameter is less than 4 digits.\n");
        str[i] = '\0';
        fseek(file, -1, SEEK_CUR);
      } else {
        printf("Error: Expected number.\n");
        exit(1);
      }
    }
  }
  return atoi(str);
}


x86 assembly (clang, -O0):
<read_number>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %rdi,-0x8(%rbp)
lea    -0xd(%rbp),%rdi
mov    -0x8(%rbp),%rcx
mov    $0x1,%esi
mov    $0x4,%edx
call   1030 <fread@plt>
movb   $0x0,-0x9(%rbp)
movl   $0x0,-0x14(%rbp)
cmpl   $0x4,-0x14(%rbp)
jge    1227 <read_number+0xd7>
movslq -0x14(%rbp),%rax
movsbl -0xd(%rbp,%rax,1),%eax
cmp    $0x30,%eax
jl     11ac <read_number+0x5c>
movslq -0x14(%rbp),%rax
movsbl -0xd(%rbp,%rax,1),%eax
cmp    $0x39,%eax
jle    1214 <read_number+0xc4>
cmpl   $0x4,-0x14(%rbp)
jge    11f9 <read_number+0xa9>
movslq -0x14(%rbp),%rax
movsbl -0xd(%rbp,%rax,1),%eax
cmp    $0x3a,%eax
jne    11f9 <read_number+0xa9>
lea    0xe31(%rip),%rdi
call   1040 <printf@plt>
movslq -0x14(%rbp),%rax
movb   $0x0,-0xd(%rbp,%rax,1)
mov    -0x8(%rbp),%rdi
mov    0x2e00(%rip),%rax
mov    (%rax),%edx
mov    $0xffffffff,%esi
call   1050 <fseek@plt>
jmp    120f <read_number+0xbf>
lea    0xe2b(%rip),%rdi
call   1040 <printf@plt>
mov    $0x1,%edi
call   1070 <exit@plt>
jmp    1214 <read_number+0xc4>
jmp    1219 <read_number+0xc9>
mov    -0x14(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x14(%rbp)
jmp    117e <read_number+0x2e>
lea    -0xd(%rbp),%rdi
call   1060 <atoi@plt>
movzwl %ax,%eax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<read_number>:
push   %rbx
sub    $0x10,%rsp
mov    %rdi,%rbx
lea    0xb(%rsp),%rdi
mov    $0x1,%esi
mov    $0x4,%edx
mov    %rbx,%rcx
call   1040 <fread@plt>
movb   $0x0,0xf(%rsp)
mov    0xb(%rsp),%al
lea    -0x3a(%rax),%ecx
cmp    $0xf5,%cl
ja     11af <read_number+0x5f>
cmp    $0x3a,%al
jne    1268 <read_number+0x118>
lea    0xe89(%rip),%rdi
call   1030 <puts@plt>
movb   $0x0,0xb(%rsp)
mov    0x2e48(%rip),%rax
mov    (%rax),%edx
mov    %rbx,%rdi
mov    $0xffffffff,%esi
call   1050 <fseek@plt>
mov    0xc(%rsp),%al
lea    -0x3a(%rax),%ecx
cmp    $0xf5,%cl
ja     11ea <read_number+0x9a>
cmp    $0x3a,%al
jne    1268 <read_number+0x118>
lea    0xe4e(%rip),%rdi
call   1030 <puts@plt>
movb   $0x0,0xc(%rsp)
mov    0x2e0d(%rip),%rax
mov    (%rax),%edx
mov    %rbx,%rdi
mov    $0xffffffff,%esi
call   1050 <fseek@plt>
mov    0xd(%rsp),%al
lea    -0x3a(%rax),%ecx
cmp    $0xf5,%cl
ja     1221 <read_number+0xd1>
cmp    $0x3a,%al
jne    1268 <read_number+0x118>
lea    0xe17(%rip),%rdi
call   1030 <puts@plt>
movb   $0x0,0xd(%rsp)
mov    0x2dd6(%rip),%rax
mov    (%rax),%edx
mov    %rbx,%rdi
mov    $0xffffffff,%esi
call   1050 <fseek@plt>
mov    0xe(%rsp),%al
lea    -0x3a(%rax),%ecx
cmp    $0xf5,%cl
ja     1258 <read_number+0x108>
cmp    $0x3a,%al
jne    1268 <read_number+0x118>
lea    0xde0(%rip),%rdi
call   1030 <puts@plt>
movb   $0x0,0xe(%rsp)
mov    0x2d9f(%rip),%rax
mov    (%rax),%edx
mov    %rbx,%rdi
mov    $0xffffffff,%esi
call   1050 <fseek@plt>
lea    0xb(%rsp),%rdi
call   1060 <atoi@plt>
add    $0x10,%rsp
pop    %rbx
ret
lea    0xd91(%rip),%rdi
call   1030 <puts@plt>
mov    $0x1,%edi
call   1070 <exit@plt>

LLVM IR (-O0):
@.str = [43 x i8] c"Warning: Parameter is less than 4 digits.\0A\00"
@SEEK_CUR = global i32 0
@.str.1 = [25 x i8] c"Error: Expected number.\0A\00"
define zeroext i16 @read_number(i32* %0) {
%2 = alloca i32*
%3 = alloca [5 x i8]
%4 = alloca i32
store i32* %0, i32** %2
%5 = bitcast [5 x i8]* %3 to i8**
%6 = load i32*, i32** %2
%7 = call i32 @fread(i8** %5, i32 1, i32 4, i32* %6)
%8 = getelementptr inbounds [5 x i8], [5 x i8]* %3, i64 0, i64 4
store i8 0, i8* %8
store i32 0, i32* %4
br label %9
9: ; preds = %49, %1
%10 = load i32, i32* %4
%11 = icmp slt i32 %10, 4
br i1 %11, label %12, label %52
12: ; preds = %9
%13 = load i32, i32* %4
%14 = sext i32 %13 to i64
%15 = getelementptr inbounds [5 x i8], [5 x i8]* %3, i64 0, i64 %14
%16 = load i8, i8* %15
%17 = sext i8 %16 to i32
%18 = icmp slt i32 %17, 48
br i1 %18, label %26, label %19
19: ; preds = %12
%20 = load i32, i32* %4
%21 = sext i32 %20 to i64
%22 = getelementptr inbounds [5 x i8], [5 x i8]* %3, i64 0, i64 %21
%23 = load i8, i8* %22
%24 = sext i8 %23 to i32
%25 = icmp sgt i32 %24, 57
br i1 %25, label %26, label %48
26: ; preds = %19, %12
%27 = load i32, i32* %4
%28 = icmp slt i32 %27, 4
br i1 %28, label %29, label %44
29: ; preds = %26
%30 = load i32, i32* %4
%31 = sext i32 %30 to i64
%32 = getelementptr inbounds [5 x i8], [5 x i8]* %3, i64 0, i64 %31
%33 = load i8, i8* %32
%34 = sext i8 %33 to i32
%35 = icmp eq i32 %34, 58
br i1 %35, label %36, label %44
36: ; preds = %29
%37 = call i32 @printf(i8* getelementptr inbounds ([43 x i8], [43 x i8]* @.str, i64 0, i64 0))
%38 = load i32, i32* %4
%39 = sext i32 %38 to i64
%40 = getelementptr inbounds [5 x i8], [5 x i8]* %3, i64 0, i64 %39
store i8 0, i8* %40
%41 = load i32*, i32** %2
%42 = load i32, i32* @SEEK_CUR
%43 = call i32 @fseek(i32* %41, i32 -1, i32 %42)
br label %47
44: ; preds = %29, %26
%45 = call i32 @printf(i8* getelementptr inbounds ([25 x i8], [25 x i8]* @.str.1, i64 0, i64 0))
%46 = call i32 @exit(i32 1)
unreachable
47: ; preds = %36
br label %48
48: ; preds = %47, %19
br label %49
49: ; preds = %48
%50 = load i32, i32* %4
%51 = add nsw i32 %50, 1
store i32 %51, i32* %4
br label %9
52: ; preds = %9
%53 = getelementptr inbounds [5 x i8], [5 x i8]* %3, i64 0, i64 0
%54 = call zeroext i16 @atoi(i8* %53)
ret i16 %54
}

LLVM IR (-O2):
@SEEK_CUR = global i32 0
@str = [24 x i8] c"Error: Expected number.\00"
@str.2 = [42 x i8] c"Warning: Parameter is less than 4 digits.\00"
define zeroext i16 @read_number(i32* nocapture %0) {
%2 = alloca [5 x i8]
%3 = getelementptr inbounds [5 x i8], [5 x i8]* %2, i64 0, i64 0
%4 = bitcast [5 x i8]* %2 to i8**
%5 = call i32 @fread(i8** %4, i32 1, i32 4, i32* %0)
%6 = getelementptr inbounds [5 x i8], [5 x i8]* %2, i64 0, i64 4
store i8 0, i8* %6
%7 = load i8, i8* %3
%8 = add i8 %7, -58
%9 = icmp ult i8 %8, -10
br i1 %9, label %10, label %19
10: ; preds = %1
%11 = icmp eq i8 %7, 58
br i1 %11, label %12, label %16
12: ; preds = %10
%13 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([42 x i8], [42 x i8]* @str.2, i64 0, i64 0))
store i8 0, i8* %3
%14 = load i32, i32* @SEEK_CUR
%15 = tail call i32 @fseek(i32* %0, i32 -1, i32 %14)
br label %19
16: ; preds = %46, %35, %24, %10
%17 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([24 x i8], [24 x i8]* @str, i64 0, i64 0))
%18 = tail call i32 @exit(i32 1)
unreachable
19: ; preds = %1, %12
%20 = getelementptr inbounds [5 x i8], [5 x i8]* %2, i64 0, i64 1
%21 = load i8, i8* %20
%22 = add i8 %21, -58
%23 = icmp ult i8 %22, -10
br i1 %23, label %24, label %30
24: ; preds = %19
%25 = icmp eq i8 %21, 58
br i1 %25, label %26, label %16
26: ; preds = %24
%27 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([42 x i8], [42 x i8]* @str.2, i64 0, i64 0))
store i8 0, i8* %20
%28 = load i32, i32* @SEEK_CUR
%29 = tail call i32 @fseek(i32* %0, i32 -1, i32 %28)
br label %30
30: ; preds = %26, %19
%31 = getelementptr inbounds [5 x i8], [5 x i8]* %2, i64 0, i64 2
%32 = load i8, i8* %31
%33 = add i8 %32, -58
%34 = icmp ult i8 %33, -10
br i1 %34, label %35, label %41
35: ; preds = %30
%36 = icmp eq i8 %32, 58
br i1 %36, label %37, label %16
37: ; preds = %35
%38 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([42 x i8], [42 x i8]* @str.2, i64 0, i64 0))
store i8 0, i8* %31
%39 = load i32, i32* @SEEK_CUR
%40 = tail call i32 @fseek(i32* %0, i32 -1, i32 %39)
br label %41
41: ; preds = %37, %30
%42 = getelementptr inbounds [5 x i8], [5 x i8]* %2, i64 0, i64 3
%43 = load i8, i8* %42
%44 = add i8 %43, -58
%45 = icmp ult i8 %44, -10
br i1 %45, label %46, label %52
46: ; preds = %41
%47 = icmp eq i8 %43, 58
br i1 %47, label %48, label %16
48: ; preds = %46
%49 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([42 x i8], [42 x i8]* @str.2, i64 0, i64 0))
store i8 0, i8* %42
%50 = load i32, i32* @SEEK_CUR
%51 = tail call i32 @fseek(i32* %0, i32 -1, i32 %50)
br label %52
52: ; preds = %48, %41
%53 = call zeroext i16 @atoi(i8* %3)
ret i16 %53
}