#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 /*<<< orphan*/ exit(int);
int length_of(char *);
char pow(int, int);
int num_con(char s[]) {
  int i;
  int l = length_of(s);
  int ll = l;
  int num = 0;
  if (s[0] - '0' >= 1 && s[0] - '0' <= 9) {
    for (i = 0; i < l; ++i) {
      if (s[i] - '0' >= 0 && s[0] - '0' <= 9)
        num = num + (s[i] - '0') * pow(10, --ll);
      else
        exit(1);
    }
  } else
    exit(2);
  return num;
}


x86 assembly (clang, -O0):
<num_con>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %rdi,-0x8(%rbp)
mov    -0x8(%rbp),%rdi
call   1030 <length_of@plt>
mov    %eax,-0x10(%rbp)
mov    -0x10(%rbp),%eax
mov    %eax,-0x14(%rbp)
movl   $0x0,-0x18(%rbp)
mov    -0x8(%rbp),%rax
movsbl (%rax),%eax
sub    $0x30,%eax
cmp    $0x1,%eax
jl     121e <num_con+0xee>
mov    -0x8(%rbp),%rax
movsbl (%rax),%eax
sub    $0x30,%eax
cmp    $0x9,%eax
jg     121e <num_con+0xee>
movl   $0x0,-0xc(%rbp)
mov    -0xc(%rbp),%eax
cmp    -0x10(%rbp),%eax
jge    1219 <num_con+0xe9>
mov    -0x8(%rbp),%rax
movslq -0xc(%rbp),%rcx
movsbl (%rax,%rcx,1),%eax
sub    $0x30,%eax
cmp    $0x0,%eax
jl     11fc <num_con+0xcc>
mov    -0x8(%rbp),%rax
movsbl (%rax),%eax
sub    $0x30,%eax
cmp    $0x9,%eax
jg     11fc <num_con+0xcc>
mov    -0x18(%rbp),%eax
mov    %eax,-0x1c(%rbp)
mov    -0x8(%rbp),%rax
movslq -0xc(%rbp),%rcx
movsbl (%rax,%rcx,1),%eax
sub    $0x30,%eax
mov    %eax,-0x20(%rbp)
mov    -0x14(%rbp),%esi
add    $0xffffffff,%esi
mov    %esi,-0x14(%rbp)
mov    $0xa,%edi
call   1040 <pow@plt>
mov    -0x20(%rbp),%ecx
mov    %al,%dl
mov    -0x1c(%rbp),%eax
movsbl %dl,%edx
imul   %edx,%ecx
add    %ecx,%eax
mov    %eax,-0x18(%rbp)
jmp    1206 <num_con+0xd6>
mov    $0x1,%edi
call   1050 <exit@plt>
jmp    120b <num_con+0xdb>
mov    -0xc(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0xc(%rbp)
jmp    1182 <num_con+0x52>
jmp    1228 <num_con+0xf8>
mov    $0x2,%edi
call   1050 <exit@plt>
mov    -0x18(%rbp),%eax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<num_con>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
push   %rax
mov    %rdi,%r14
call   1030 <length_of@plt>
mov    %eax,%r12d
mov    (%r14),%al
lea    -0x31(%rax),%ecx
cmp    $0x8,%cl
ja     11c7 <num_con+0x97>
test   %r12d,%r12d
jle    11b2 <num_con+0x82>
cmp    $0x30,%al
jl     11a8 <num_con+0x78>
mov    %r12d,%r15d
add    $0xffffffff,%r12d
xor    %r13d,%r13d
mov    $0x1,%ebp
nopl   0x0(%rax)
cmpb   $0x39,(%r14)
jg     11a8 <num_con+0x78>
movsbl %al,%ebx
add    $0xffffffd0,%ebx
mov    $0xa,%edi
mov    %r12d,%esi
call   1040 <pow@plt>
movsbl %al,%eax
imul   %ebx,%eax
add    %eax,%r13d
cmp    %rbp,%r15
je     11b5 <num_con+0x85>
movzbl (%r14,%rbp,1),%eax
add    $0xffffffff,%r12d
add    $0x1,%rbp
cmp    $0x2f,%al
jg     1170 <num_con+0x40>
mov    $0x1,%edi
call   1050 <exit@plt>
xor    %r13d,%r13d
mov    %r13d,%eax
add    $0x8,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret
mov    $0x2,%edi
call   1050 <exit@plt>

LLVM IR (-O0):
define i32 @num_con(i8* %0) {
%2 = alloca i8*
%3 = alloca i32
%4 = alloca i32
%5 = alloca i32
%6 = alloca i32
store i8* %0, i8** %2
%7 = load i8*, i8** %2
%8 = call i32 @length_of(i8* %7)
store i32 %8, i32* %4
%9 = load i32, i32* %4
store i32 %9, i32* %5
store i32 0, i32* %6
%10 = load i8*, i8** %2
%11 = getelementptr inbounds i8, i8* %10, i64 0
%12 = load i8, i8* %11
%13 = sext i8 %12 to i32
%14 = sub nsw i32 %13, 48
%15 = icmp sge i32 %14, 1
br i1 %15, label %16, label %66
16: ; preds = %1
%17 = load i8*, i8** %2
%18 = getelementptr inbounds i8, i8* %17, i64 0
%19 = load i8, i8* %18
%20 = sext i8 %19 to i32
%21 = sub nsw i32 %20, 48
%22 = icmp sle i32 %21, 9
br i1 %22, label %23, label %66
23: ; preds = %16
store i32 0, i32* %3
br label %24
24: ; preds = %62, %23
%25 = load i32, i32* %3
%26 = load i32, i32* %4
%27 = icmp slt i32 %25, %26
br i1 %27, label %28, label %65
28: ; preds = %24
%29 = load i8*, i8** %2
%30 = load i32, i32* %3
%31 = sext i32 %30 to i64
%32 = getelementptr inbounds i8, i8* %29, i64 %31
%33 = load i8, i8* %32
%34 = sext i8 %33 to i32
%35 = sub nsw i32 %34, 48
%36 = icmp sge i32 %35, 0
br i1 %36, label %37, label %59
37: ; preds = %28
%38 = load i8*, i8** %2
%39 = getelementptr inbounds i8, i8* %38, i64 0
%40 = load i8, i8* %39
%41 = sext i8 %40 to i32
%42 = sub nsw i32 %41, 48
%43 = icmp sle i32 %42, 9
br i1 %43, label %44, label %59
44: ; preds = %37
%45 = load i32, i32* %6
%46 = load i8*, i8** %2
%47 = load i32, i32* %3
%48 = sext i32 %47 to i64
%49 = getelementptr inbounds i8, i8* %46, i64 %48
%50 = load i8, i8* %49
%51 = sext i8 %50 to i32
%52 = sub nsw i32 %51, 48
%53 = load i32, i32* %5
%54 = add nsw i32 %53, -1
store i32 %54, i32* %5
%55 = call signext i8 @pow(i32 10, i32 %54)
%56 = sext i8 %55 to i32
%57 = mul nsw i32 %52, %56
%58 = add nsw i32 %45, %57
store i32 %58, i32* %6
br label %61
59: ; preds = %37, %28
%60 = call i32 @exit(i32 1)
unreachable
61: ; preds = %44
br label %62
62: ; preds = %61
%63 = load i32, i32* %3
%64 = add nsw i32 %63, 1
store i32 %64, i32* %3
br label %24
65: ; preds = %24
br label %68
66: ; preds = %16, %1
%67 = call i32 @exit(i32 2)
unreachable
68: ; preds = %65
%69 = load i32, i32* %6
ret i32 %69
}

LLVM IR (-O2):
define i32 @num_con(i8* %0) {
%2 = tail call i32 @length_of(i8* %0)
%3 = load i8, i8* %0
%4 = add i8 %3, -49
%5 = icmp ult i8 %4, 9
br i1 %5, label %6, label %34
6: ; preds = %1
%7 = icmp sgt i32 %2, 0
br i1 %7, label %8, label %36
8: ; preds = %6
%9 = zext i32 %2 to i64
%10 = icmp sgt i8 %3, 47
br i1 %10, label %11, label %32
11: ; preds = %8, %28
%12 = phi i8 [ %30, %28 ], [ %3, %8 ]
%13 = phi i32 [ %21, %28 ], [ %2, %8 ]
%14 = phi i32 [ %25, %28 ], [ 0, %8 ]
%15 = phi i64 [ %26, %28 ], [ 0, %8 ]
%16 = load i8, i8* %0
%17 = icmp slt i8 %16, 58
br i1 %17, label %18, label %32
18: ; preds = %11
%19 = sext i8 %12 to i32
%20 = add nsw i32 %19, -48
%21 = add nsw i32 %13, -1
%22 = tail call signext i8 @pow(i32 10, i32 %21)
%23 = sext i8 %22 to i32
%24 = mul nsw i32 %20, %23
%25 = add nsw i32 %24, %14
%26 = add nuw nsw i64 %15, 1
%27 = icmp eq i64 %26, %9
br i1 %27, label %36, label %28
28: ; preds = %18
%29 = getelementptr inbounds i8, i8* %0, i64 %26
%30 = load i8, i8* %29
%31 = icmp sgt i8 %30, 47
br i1 %31, label %11, label %32
32: ; preds = %28, %11, %8
%33 = tail call i32 @exit(i32 1)
unreachable
34: ; preds = %1
%35 = tail call i32 @exit(i32 2)
unreachable
36: ; preds = %18, %6
%37 = phi i32 [ 0, %6 ], [ %25, %18 ]
ret i32 %37
}