#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*/ assert(int);
int atof(char *);
int round(int);
int main(void) {
  assert(atof("123") == 123);
  assert(atof("1.23") == 1.23);
  assert(atof("12.3e2") == 1230);
  assert(atof("12.3e+2") == 1230);
  assert((round(atof("123e-2") * 100) / 100) == 1.23);
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
movl   $0x0,-0x4(%rbp)
lea    0xec2(%rip),%rdi
call   1030 <atof@plt>
cmp    $0x7b,%eax
sete   %al
and    $0x1,%al
movzbl %al,%edi
call   1040 <assert@plt>
lea    0xeaa(%rip),%rdi
call   1030 <atof@plt>
cvtsi2sd %eax,%xmm0
movsd  0xe8d(%rip),%xmm1
ucomisd %xmm1,%xmm0
sete   %al
setnp  %cl
and    %cl,%al
and    $0x1,%al
movzbl %al,%edi
call   1040 <assert@plt>
lea    0xe81(%rip),%rdi
call   1030 <atof@plt>
cmp    $0x4ce,%eax
sete   %al
and    $0x1,%al
movzbl %al,%edi
call   1040 <assert@plt>
lea    0xe6a(%rip),%rdi
call   1030 <atof@plt>
cmp    $0x4ce,%eax
sete   %al
and    $0x1,%al
movzbl %al,%edi
call   1040 <assert@plt>
lea    0xe54(%rip),%rdi
call   1030 <atof@plt>
imul   $0x64,%eax,%edi
call   1050 <round@plt>
mov    $0x64,%ecx
cltd
idiv   %ecx
cvtsi2sd %eax,%xmm0
movsd  0xe13(%rip),%xmm1
ucomisd %xmm1,%xmm0
sete   %al
setnp  %cl
and    %cl,%al
and    $0x1,%al
movzbl %al,%edi
call   1040 <assert@plt>
xor    %eax,%eax
add    $0x10,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rax
lea    0xec8(%rip),%rdi
call   1030 <atof@plt>
xor    %edi,%edi
cmp    $0x7b,%eax
sete   %dil
call   1040 <assert@plt>
xor    %edi,%edi
call   1040 <assert@plt>
lea    0xeab(%rip),%rdi
call   1030 <atof@plt>
xor    %edi,%edi
cmp    $0x4ce,%eax
sete   %dil
call   1040 <assert@plt>
lea    0xe96(%rip),%rdi
call   1030 <atof@plt>
xor    %edi,%edi
cmp    $0x4ce,%eax
sete   %dil
call   1040 <assert@plt>
lea    0xe82(%rip),%rdi
call   1030 <atof@plt>
imul   $0x64,%eax,%edi
call   1050 <round@plt>
xor    %edi,%edi
call   1040 <assert@plt>
xor    %eax,%eax
pop    %rcx
ret

LLVM IR (-O0):
@.str = [4 x i8] c"123\00"
@.str.1 = [5 x i8] c"1.23\00"
@.str.2 = [7 x i8] c"12.3e2\00"
@.str.3 = [8 x i8] c"12.3e+2\00"
@.str.4 = [7 x i8] c"123e-2\00"
define i32 @main() {
%1 = alloca i32
store i32 0, i32* %1
%2 = call i32 @atof(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str, i64 0, i64 0))
%3 = icmp eq i32 %2, 123
%4 = zext i1 %3 to i32
%5 = call i32 @assert(i32 %4)
%6 = call i32 @atof(i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.1, i64 0, i64 0))
%7 = sitofp i32 %6 to double
%8 = fcmp oeq double %7, 1.230000e+00
%9 = zext i1 %8 to i32
%10 = call i32 @assert(i32 %9)
%11 = call i32 @atof(i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str.2, i64 0, i64 0))
%12 = icmp eq i32 %11, 1230
%13 = zext i1 %12 to i32
%14 = call i32 @assert(i32 %13)
%15 = call i32 @atof(i8* getelementptr inbounds ([8 x i8], [8 x i8]* @.str.3, i64 0, i64 0))
%16 = icmp eq i32 %15, 1230
%17 = zext i1 %16 to i32
%18 = call i32 @assert(i32 %17)
%19 = call i32 @atof(i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str.4, i64 0, i64 0))
%20 = mul nsw i32 %19, 100
%21 = call i32 @round(i32 %20)
%22 = sdiv i32 %21, 100
%23 = sitofp i32 %22 to double
%24 = fcmp oeq double %23, 1.230000e+00
%25 = zext i1 %24 to i32
%26 = call i32 @assert(i32 %25)
ret i32 0
}

LLVM IR (-O2):
@.str = [4 x i8] c"123\00"
@.str.2 = [7 x i8] c"12.3e2\00"
@.str.3 = [8 x i8] c"12.3e+2\00"
@.str.4 = [7 x i8] c"123e-2\00"
define i32 @main() {
%1 = tail call i32 @atof(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str, i64 0, i64 0))
%2 = icmp eq i32 %1, 123
%3 = zext i1 %2 to i32
%4 = tail call i32 @assert(i32 %3)
%5 = tail call i32 @assert(i32 0)
%6 = tail call i32 @atof(i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str.2, i64 0, i64 0))
%7 = icmp eq i32 %6, 1230
%8 = zext i1 %7 to i32
%9 = tail call i32 @assert(i32 %8)
%10 = tail call i32 @atof(i8* getelementptr inbounds ([8 x i8], [8 x i8]* @.str.3, i64 0, i64 0))
%11 = icmp eq i32 %10, 1230
%12 = zext i1 %11 to i32
%13 = tail call i32 @assert(i32 %12)
%14 = tail call i32 @atof(i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str.4, i64 0, i64 0))
%15 = mul nsw i32 %14, 100
%16 = tail call i32 @round(i32 %15)
%17 = tail call i32 @assert(i32 0)
ret i32 0
}