#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 *);
int /*<<< orphan*/ exit(int /*<<< orphan*/);
char getchar();
int /*<<< orphan*/ perror(char *);
int main(int argc, char *argv[]) {
  int len = 0;
  char ch;
  char buf[3];
  int ret;
  ch = getchar();
  while (len < 3 && ch != '\n') {
    buf[len++] = ch;
    ch = getchar();
  }
  ret = atoi(buf);
  if (ret > 255) {
    perror("exit code can not be bigger than 255\n");
    exit(0);
  }
  return ret;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
movl   $0x0,-0x4(%rbp)
mov    %edi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
movl   $0x0,-0x14(%rbp)
mov    $0x0,%al
call   1030 <getchar@plt>
mov    %al,-0x15(%rbp)
xor    %eax,%eax
cmpl   $0x3,-0x14(%rbp)
mov    %al,-0x1d(%rbp)
jge    1183 <main+0x43>
movsbl -0x15(%rbp),%eax
cmp    $0xa,%eax
setne  %al
mov    %al,-0x1d(%rbp)
mov    -0x1d(%rbp),%al
test   $0x1,%al
jne    1193 <main+0x53>
jmp    11b6 <main+0x76>
mov    -0x15(%rbp),%cl
mov    -0x14(%rbp),%eax
mov    %eax,%edx
add    $0x1,%edx
mov    %edx,-0x14(%rbp)
cltq
mov    %cl,-0x18(%rbp,%rax,1)
mov    $0x0,%al
call   1030 <getchar@plt>
mov    %al,-0x15(%rbp)
jmp    1167 <main+0x27>
lea    -0x18(%rbp),%rdi
call   1050 <atoi@plt>
mov    %eax,-0x1c(%rbp)
cmpl   $0xff,-0x1c(%rbp)
jle    11e2 <main+0xa2>
lea    0xe2a(%rip),%rdi
call   1040 <perror@plt>
xor    %edi,%edi
call   1060 <exit@plt>
mov    -0x1c(%rbp),%eax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbx
sub    $0x10,%rsp
xor    %eax,%eax
call   1030 <getchar@plt>
cmp    $0xa,%al
je     1179 <main+0x39>
xor    %ebx,%ebx
cs nopw 0x0(%rax,%rax,1)
nopl   0x0(%rax)
mov    %al,0xd(%rsp,%rbx,1)
xor    %eax,%eax
call   1030 <getchar@plt>
cmp    $0x1,%rbx
ja     1179 <main+0x39>
add    $0x1,%rbx
cmp    $0xa,%al
jne    1160 <main+0x20>
lea    0xd(%rsp),%rdi
call   1050 <atoi@plt>
cmp    $0x100,%eax
jge    1190 <main+0x50>
add    $0x10,%rsp
pop    %rbx
ret
lea    0xe69(%rip),%rdi
call   1040 <perror@plt>
xor    %edi,%edi
call   1060 <exit@plt>

LLVM IR (-O0):
@.str = [38 x i8] c"exit code can not be bigger than 255\0A\00"
define i32 @main(i32 %0, i8** %1) {
%3 = alloca i32
%4 = alloca i32
%5 = alloca i8**
%6 = alloca i32
%7 = alloca i8
%8 = alloca [3 x i8]
%9 = alloca i32
store i32 0, i32* %3
store i32 %0, i32* %4
store i8** %1, i8*** %5
store i32 0, i32* %6
%10 = call signext i8 (...) @getchar()
store i8 %10, i8* %7
br label %11
11: ; preds = %20, %2
%12 = load i32, i32* %6
%13 = icmp slt i32 %12, 3
br i1 %13, label %14, label %18
14: ; preds = %11
%15 = load i8, i8* %7
%16 = sext i8 %15 to i32
%17 = icmp ne i32 %16, 10
br label %18
18: ; preds = %14, %11
%19 = phi i1 [ false, %11 ], [ %17, %14 ]
br i1 %19, label %20, label %27
20: ; preds = %18
%21 = load i8, i8* %7
%22 = load i32, i32* %6
%23 = add nsw i32 %22, 1
store i32 %23, i32* %6
%24 = sext i32 %22 to i64
%25 = getelementptr inbounds [3 x i8], [3 x i8]* %8, i64 0, i64 %24
store i8 %21, i8* %25
%26 = call signext i8 (...) @getchar()
store i8 %26, i8* %7
br label %11
27: ; preds = %18
%28 = getelementptr inbounds [3 x i8], [3 x i8]* %8, i64 0, i64 0
%29 = call i32 @atoi(i8* %28)
store i32 %29, i32* %9
%30 = load i32, i32* %9
%31 = icmp sgt i32 %30, 255
br i1 %31, label %32, label %35
32: ; preds = %27
%33 = call i32 @perror(i8* getelementptr inbounds ([38 x i8], [38 x i8]* @.str, i64 0, i64 0))
%34 = call i32 @exit(i32 0)
unreachable
35: ; preds = %27
%36 = load i32, i32* %9
ret i32 %36
}

LLVM IR (-O2):
@.str = [38 x i8] c"exit code can not be bigger than 255\0A\00"
define i32 @main(i32 %0, i8** nocapture readnone %1) {
%3 = alloca [3 x i8]
%4 = getelementptr inbounds [3 x i8], [3 x i8]* %3, i64 0, i64 0
%5 = tail call signext i8 (...) @getchar()
%6 = icmp eq i8 %5, 10
br i1 %6, label %16, label %7
7: ; preds = %2, %7
%8 = phi i64 [ %10, %7 ], [ 0, %2 ]
%9 = phi i8 [ %12, %7 ], [ %5, %2 ]
%10 = add nuw nsw i64 %8, 1
%11 = getelementptr inbounds [3 x i8], [3 x i8]* %3, i64 0, i64 %8
store i8 %9, i8* %11
%12 = tail call signext i8 (...) @getchar()
%13 = icmp ult i64 %8, 2
%14 = icmp ne i8 %12, 10
%15 = and i1 %13, %14
br i1 %15, label %7, label %16
16: ; preds = %7, %2
%17 = call i32 @atoi(i8* %4)
%18 = icmp sgt i32 %17, 255
br i1 %18, label %19, label %22
19: ; preds = %16
%20 = tail call i32 @perror(i8* getelementptr inbounds ([38 x i8], [38 x i8]* @.str, i64 0, i64 0))
%21 = tail call i32 @exit(i32 0)
unreachable
22: ; preds = %16
ret i32 %17
}