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

/* Variables and functions */
int atoi(char *);
scalar_t__ isdigit(char);
int /*<<< orphan*/ printf(char *);
int /*<<< orphan*/ sleep(int /*<<< orphan*/);
bool id_registered(char *id) {
  int numeric_id = 0;
  printf("Checking if ID is valid...\n");
  sleep(0);
  if (isdigit(id[0]) && isdigit(id[1]) && isdigit(id[2]) && isdigit(id[3])) {
    numeric_id = atoi(id);
    if (0 <= numeric_id && numeric_id <= 1000 && numeric_id != 0) {
      return true;
    } else {
      return false;
    }
  } else {
    return false;
  }
}


x86 assembly (clang, -O0):
<id_registered>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %rdi,-0x10(%rbp)
movl   $0x0,-0x14(%rbp)
lea    0xea6(%rip),%rdi
call   1040 <printf@plt>
xor    %edi,%edi
call   1060 <sleep@plt>
mov    -0x10(%rbp),%rax
movsbl (%rax),%edi
call   1030 <isdigit@plt>
cmp    $0x0,%rax
je     1207 <id_registered+0xc7>
mov    -0x10(%rbp),%rax
movsbl 0x1(%rax),%edi
call   1030 <isdigit@plt>
cmp    $0x0,%rax
je     1207 <id_registered+0xc7>
mov    -0x10(%rbp),%rax
movsbl 0x2(%rax),%edi
call   1030 <isdigit@plt>
cmp    $0x0,%rax
je     1207 <id_registered+0xc7>
mov    -0x10(%rbp),%rax
movsbl 0x3(%rax),%edi
call   1030 <isdigit@plt>
cmp    $0x0,%rax
je     1207 <id_registered+0xc7>
mov    -0x10(%rbp),%rdi
call   1050 <atoi@plt>
mov    %eax,-0x14(%rbp)
xor    %eax,%eax
cmp    -0x14(%rbp),%eax
jg     11fb <id_registered+0xbb>
cmpl   $0x3e8,-0x14(%rbp)
jg     11fb <id_registered+0xbb>
cmpl   $0x0,-0x14(%rbp)
je     11fb <id_registered+0xbb>
movl   $0x1,-0x4(%rbp)
jmp    120e <id_registered+0xce>
movl   $0x0,-0x4(%rbp)
jmp    120e <id_registered+0xce>
movl   $0x0,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<id_registered>:
push   %rbp
push   %rbx
push   %rax
mov    %rdi,%rbx
lea    0xeb3(%rip),%rdi
call   1040 <puts@plt>
xor    %ebp,%ebp
xor    %edi,%edi
call   1060 <sleep@plt>
movsbl (%rbx),%edi
call   1030 <isdigit@plt>
test   %rax,%rax
je     11a8 <id_registered+0x68>
movsbl 0x1(%rbx),%edi
call   1030 <isdigit@plt>
test   %rax,%rax
je     11a8 <id_registered+0x68>
movsbl 0x2(%rbx),%edi
call   1030 <isdigit@plt>
test   %rax,%rax
je     11a8 <id_registered+0x68>
movsbl 0x3(%rbx),%edi
call   1030 <isdigit@plt>
test   %rax,%rax
je     11a8 <id_registered+0x68>
mov    %rbx,%rdi
call   1050 <atoi@plt>
add    $0xffffffff,%eax
xor    %ebp,%ebp
cmp    $0x3e8,%eax
setb   %bpl
mov    %ebp,%eax
add    $0x8,%rsp
pop    %rbx
pop    %rbp
ret

LLVM IR (-O0):
@.str = [28 x i8] c"Checking if ID is valid...\0A\00"
define i32 @id_registered(i8* %0) {
%2 = alloca i32
%3 = alloca i8*
%4 = alloca i32
store i8* %0, i8** %3
store i32 0, i32* %4
%5 = call i32 @printf(i8* getelementptr inbounds ([28 x i8], [28 x i8]* @.str, i64 0, i64 0))
%6 = call i32 @sleep(i32 0)
%7 = load i8*, i8** %3
%8 = getelementptr inbounds i8, i8* %7, i64 0
%9 = load i8, i8* %8
%10 = call i64 @isdigit(i8 signext %9)
%11 = icmp ne i64 %10, 0
br i1 %11, label %12, label %43
12: ; preds = %1
%13 = load i8*, i8** %3
%14 = getelementptr inbounds i8, i8* %13, i64 1
%15 = load i8, i8* %14
%16 = call i64 @isdigit(i8 signext %15)
%17 = icmp ne i64 %16, 0
br i1 %17, label %18, label %43
18: ; preds = %12
%19 = load i8*, i8** %3
%20 = getelementptr inbounds i8, i8* %19, i64 2
%21 = load i8, i8* %20
%22 = call i64 @isdigit(i8 signext %21)
%23 = icmp ne i64 %22, 0
br i1 %23, label %24, label %43
24: ; preds = %18
%25 = load i8*, i8** %3
%26 = getelementptr inbounds i8, i8* %25, i64 3
%27 = load i8, i8* %26
%28 = call i64 @isdigit(i8 signext %27)
%29 = icmp ne i64 %28, 0
br i1 %29, label %30, label %43
30: ; preds = %24
%31 = load i8*, i8** %3
%32 = call i32 @atoi(i8* %31)
store i32 %32, i32* %4
%33 = load i32, i32* %4
%34 = icmp sle i32 0, %33
br i1 %34, label %35, label %42
35: ; preds = %30
%36 = load i32, i32* %4
%37 = icmp sle i32 %36, 1000
br i1 %37, label %38, label %42
38: ; preds = %35
%39 = load i32, i32* %4
%40 = icmp ne i32 %39, 0
br i1 %40, label %41, label %42
41: ; preds = %38
store i32 1, i32* %2
br label %44
42: ; preds = %38, %35, %30
store i32 0, i32* %2
br label %44
43: ; preds = %24, %18, %12, %1
store i32 0, i32* %2
br label %44
44: ; preds = %43, %42, %41
%45 = load i32, i32* %2
ret i32 %45
}

LLVM IR (-O2):
@str = [27 x i8] c"Checking if ID is valid...\00"
define i32 @id_registered(i8* nocapture %0) {
%2 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([27 x i8], [27 x i8]* @str, i64 0, i64 0))
%3 = tail call i32 @sleep(i32 0)
%4 = load i8, i8* %0
%5 = tail call i64 @isdigit(i8 signext %4)
%6 = icmp eq i64 %5, 0
br i1 %6, label %27, label %7
7: ; preds = %1
%8 = getelementptr inbounds i8, i8* %0, i64 1
%9 = load i8, i8* %8
%10 = tail call i64 @isdigit(i8 signext %9)
%11 = icmp eq i64 %10, 0
br i1 %11, label %27, label %12
12: ; preds = %7
%13 = getelementptr inbounds i8, i8* %0, i64 2
%14 = load i8, i8* %13
%15 = tail call i64 @isdigit(i8 signext %14)
%16 = icmp eq i64 %15, 0
br i1 %16, label %27, label %17
17: ; preds = %12
%18 = getelementptr inbounds i8, i8* %0, i64 3
%19 = load i8, i8* %18
%20 = tail call i64 @isdigit(i8 signext %19)
%21 = icmp eq i64 %20, 0
br i1 %21, label %27, label %22
22: ; preds = %17
%23 = tail call i32 @atoi(i8* %0)
%24 = add i32 %23, -1
%25 = icmp ult i32 %24, 1000
%26 = zext i1 %25 to i32
br label %27
27: ; preds = %1, %7, %12, %17, %22
%28 = phi i32 [ %26, %22 ], [ 0, %17 ], [ 0, %12 ], [ 0, %7 ], [ 0, %1 ]
ret i32 %28
}