#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 */
scalar_t__ ERANGE;
double HUGE_VAL;
scalar_t__ errno;
int /*<<< orphan*/ fprintf(int /*<<< orphan*/, char *);
int /*<<< orphan*/ printf(char *, char *, ...);
int /*<<< orphan*/ stderr;
double strtod(char *, char **);
int main(int argc, char *argv[]) {
  int i;
  char *ep;
  double lval;
  if (argc < 2) {
    printf("Usage: %s base 'string' [base 'string']...\n", argv[0]);
    return 0;
  }
  for (i = 1; i < argc; i++) {
    errno = 0;
    lval = strtod(argv[i], &ep);
    if (lval == 0.0) {
      if (errno == ERANGE) {
        fprintf(stderr, "Value is too small!\n");
        return 1;
      }
    } else {
      if (lval == HUGE_VAL) {
        if (errno == ERANGE) {
          fprintf(stderr, "upper overflowing\n");
          return 1;
        }
      } else if (lval == -HUGE_VAL) {
        if (errno == ERANGE) {
          fprintf(stderr, "lower overflowing\n");
          return 1;
        }
      }
    }
    printf("'%s' ==> %g\n", argv[i], lval);
  }
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
movl   $0x0,-0x4(%rbp)
mov    %edi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
cmpl   $0x2,-0x8(%rbp)
jge    1171 <main+0x41>
mov    -0x10(%rbp),%rax
mov    (%rax),%rsi
lea    0xea2(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
movl   $0x0,-0x4(%rbp)
jmp    1315 <main+0x1e5>
movl   $0x1,-0x14(%rbp)
mov    -0x14(%rbp),%eax
cmp    -0x8(%rbp),%eax
jge    130e <main+0x1de>
mov    0x2e3d(%rip),%rax
movq   $0x0,(%rax)
mov    -0x10(%rbp),%rax
movslq -0x14(%rbp),%rcx
mov    (%rax,%rcx,8),%rdi
lea    -0x20(%rbp),%rsi
call   1030 <strtod@plt>
movsd  %xmm0,-0x28(%rbp)
movsd  -0x28(%rbp),%xmm0
xorps  %xmm1,%xmm1
ucomisd %xmm1,%xmm0
jne    1204 <main+0xd4>
jp     1204 <main+0xd4>
mov    0x2dfd(%rip),%rax
mov    (%rax),%rax
mov    0x2e0b(%rip),%rcx
cmp    (%rcx),%rax
jne    11ff <main+0xcf>
mov    0x2deb(%rip),%rax
mov    (%rax),%edi
lea    0xe3e(%rip),%rsi
call   1050 <fprintf@plt>
movl   $0x1,-0x4(%rbp)
jmp    1315 <main+0x1e5>
jmp    12e1 <main+0x1b1>
movsd  -0x28(%rbp),%xmm0
mov    0x2dd8(%rip),%rax
ucomisd (%rax),%xmm0
jne    1260 <main+0x130>
jp     1260 <main+0x130>
mov    0x2da1(%rip),%rax
mov    (%rax),%rax
mov    0x2daf(%rip),%rcx
cmp    (%rcx),%rax
jne    125b <main+0x12b>
mov    0x2d8f(%rip),%rax
mov    (%rax),%edi
lea    0xdf7(%rip),%rsi
call   1050 <fprintf@plt>
movl   $0x1,-0x4(%rbp)
jmp    1315 <main+0x1e5>
jmp    12dc <main+0x1ac>
movsd  -0x28(%rbp),%xmm0
mov    0x2d7c(%rip),%rax
movsd  (%rax),%xmm1
movq   %xmm1,%rax
movabs $0x8000000000000000,%rcx
xor    %rcx,%rax
movq   %rax,%xmm1
ucomisd %xmm1,%xmm0
jne    12d7 <main+0x1a7>
jp     12d7 <main+0x1a7>
mov    0x2d2a(%rip),%rax
mov    (%rax),%rax
mov    0x2d38(%rip),%rcx
cmp    (%rcx),%rax
jne    12d2 <main+0x1a2>
mov    0x2d18(%rip),%rax
mov    (%rax),%edi
lea    0xd93(%rip),%rsi
call   1050 <fprintf@plt>
movl   $0x1,-0x4(%rbp)
jmp    1315 <main+0x1e5>
jmp    12d7 <main+0x1a7>
jmp    12dc <main+0x1ac>
jmp    12e1 <main+0x1b1>
mov    -0x10(%rbp),%rax
movslq -0x14(%rbp),%rcx
mov    (%rax,%rcx,8),%rsi
movsd  -0x28(%rbp),%xmm0
lea    0xd6e(%rip),%rdi
mov    $0x1,%al
call   1040 <printf@plt>
mov    -0x14(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x14(%rbp)
jmp    1178 <main+0x48>
movl   $0x0,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
push   %rax
mov    %rsi,%r13
cmp    $0x2,%edi
jge    115c <main+0x2c>
mov    0x0(%r13),%rsi
lea    0xeca(%rip),%rdi
xor    %ebx,%ebx
xor    %eax,%eax
call   1040 <printf@plt>
jmp    1254 <main+0x124>
mov    %edi,%r12d
mov    $0x1,%ebx
mov    0x2e5d(%rip),%rbp
mov    %rsp,%r14
lea    0xf0a(%rip),%r15
jmp    11ac <main+0x7c>
nopw   0x0(%rax,%rax,1)
mov    0x0(%rbp),%rax
mov    0x2e55(%rip),%rcx
cmp    (%rcx),%rax
je     1228 <main+0xf8>
mov    0x0(%r13,%rbx,8),%rsi
mov    %r15,%rdi
mov    $0x1,%al
call   1040 <printf@plt>
add    $0x1,%rbx
cmp    %rbx,%r12
je     1224 <main+0xf4>
movq   $0x0,0x0(%rbp)
mov    0x0(%r13,%rbx,8),%rdi
mov    %r14,%rsi
call   1030 <strtod@plt>
ucomisd 0xe47(%rip),%xmm0
jne    11cd <main+0x9d>
jnp    1180 <main+0x50>
mov    0x2e14(%rip),%rax
movsd  (%rax),%xmm1
ucomisd %xmm1,%xmm0
jne    11f2 <main+0xc2>
jp     11f2 <main+0xc2>
mov    0x0(%rbp),%rax
mov    0x2df5(%rip),%rcx
cmp    (%rcx),%rax
jne    1194 <main+0x64>
jmp    123a <main+0x10a>
xorpd  0xe06(%rip),%xmm1
ucomisd %xmm1,%xmm0
jne    1194 <main+0x64>
jp     1194 <main+0x64>
mov    0x0(%rbp),%rax
mov    0x2dd3(%rip),%rcx
cmp    (%rcx),%rax
jne    1194 <main+0x64>
mov    0x2db7(%rip),%rax
mov    (%rax),%edi
lea    0xe4a(%rip),%rsi
jmp    124a <main+0x11a>
xor    %ebx,%ebx
jmp    1254 <main+0x124>
mov    0x2da1(%rip),%rax
mov    (%rax),%edi
lea    0xe0c(%rip),%rsi
jmp    124a <main+0x11a>
mov    0x2d8f(%rip),%rax
mov    (%rax),%edi
lea    0xe0f(%rip),%rsi
call   1050 <fprintf@plt>
mov    $0x1,%ebx
mov    %ebx,%eax
add    $0x8,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
@.str = [44 x i8] c"Usage: %s base 'string' [base 'string']...\0A\00"
@errno = global i64 0
@ERANGE = global i64 0
@stderr = global i32 0
@.str.1 = [21 x i8] c"Value is too small!\0A\00"
@HUGE_VAL = global double 0.000000e+00
@.str.2 = [19 x i8] c"upper overflowing\0A\00"
@.str.3 = [19 x i8] c"lower overflowing\0A\00"
@.str.4 = [13 x i8] c"'%s' ==> %g\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 double
store i32 0, i32* %3
store i32 %0, i32* %4
store i8** %1, i8*** %5
%9 = load i32, i32* %4
%10 = icmp slt i32 %9, 2
br i1 %10, label %11, label %16
11: ; preds = %2
%12 = load i8**, i8*** %5
%13 = getelementptr inbounds i8*, i8** %12, i64 0
%14 = load i8*, i8** %13
%15 = call i32 (i8*, i8*, ...) @printf(i8* getelementptr inbounds ([44 x i8], [44 x i8]* @.str, i64 0, i64 0), i8* %14)
store i32 0, i32* %3
br label %77
16: ; preds = %2
store i32 1, i32* %6
br label %17
17: ; preds = %73, %16
%18 = load i32, i32* %6
%19 = load i32, i32* %4
%20 = icmp slt i32 %18, %19
br i1 %20, label %21, label %76
21: ; preds = %17
store i64 0, i64* @errno
%22 = load i8**, i8*** %5
%23 = load i32, i32* %6
%24 = sext i32 %23 to i64
%25 = getelementptr inbounds i8*, i8** %22, i64 %24
%26 = load i8*, i8** %25
%27 = call double @strtod(i8* %26, i8** %7)
store double %27, double* %8
%28 = load double, double* %8
%29 = fcmp oeq double %28, 0.000000e+00
br i1 %29, label %30, label %38
30: ; preds = %21
%31 = load i64, i64* @errno
%32 = load i64, i64* @ERANGE
%33 = icmp eq i64 %31, %32
br i1 %33, label %34, label %37
34: ; preds = %30
%35 = load i32, i32* @stderr
%36 = call i32 @fprintf(i32 %35, i8* getelementptr inbounds ([21 x i8], [21 x i8]* @.str.1, i64 0, i64 0))
store i32 1, i32* %3
br label %77
37: ; preds = %30
br label %65
38: ; preds = %21
%39 = load double, double* %8
%40 = load double, double* @HUGE_VAL
%41 = fcmp oeq double %39, %40
br i1 %41, label %42, label %50
42: ; preds = %38
%43 = load i64, i64* @errno
%44 = load i64, i64* @ERANGE
%45 = icmp eq i64 %43, %44
br i1 %45, label %46, label %49
46: ; preds = %42
%47 = load i32, i32* @stderr
%48 = call i32 @fprintf(i32 %47, i8* getelementptr inbounds ([19 x i8], [19 x i8]* @.str.2, i64 0, i64 0))
store i32 1, i32* %3
br label %77
49: ; preds = %42
br label %64
50: ; preds = %38
%51 = load double, double* %8
%52 = load double, double* @HUGE_VAL
%53 = fneg double %52
%54 = fcmp oeq double %51, %53
br i1 %54, label %55, label %63
55: ; preds = %50
%56 = load i64, i64* @errno
%57 = load i64, i64* @ERANGE
%58 = icmp eq i64 %56, %57
br i1 %58, label %59, label %62
59: ; preds = %55
%60 = load i32, i32* @stderr
%61 = call i32 @fprintf(i32 %60, i8* getelementptr inbounds ([19 x i8], [19 x i8]* @.str.3, i64 0, i64 0))
store i32 1, i32* %3
br label %77
62: ; preds = %55
br label %63
63: ; preds = %62, %50
br label %64
64: ; preds = %63, %49
br label %65
65: ; preds = %64, %37
%66 = load i8**, i8*** %5
%67 = load i32, i32* %6
%68 = sext i32 %67 to i64
%69 = getelementptr inbounds i8*, i8** %66, i64 %68
%70 = load i8*, i8** %69
%71 = load double, double* %8
%72 = call i32 (i8*, i8*, ...) @printf(i8* getelementptr inbounds ([13 x i8], [13 x i8]* @.str.4, i64 0, i64 0), i8* %70, double %71)
br label %73
73: ; preds = %65
%74 = load i32, i32* %6
%75 = add nsw i32 %74, 1
store i32 %75, i32* %6
br label %17
76: ; preds = %17
store i32 0, i32* %3
br label %77
77: ; preds = %76, %59, %46, %34, %11
%78 = load i32, i32* %3
ret i32 %78
}

LLVM IR (-O2):
@.str = [44 x i8] c"Usage: %s base 'string' [base 'string']...\0A\00"
@errno = global i64 0
@ERANGE = global i64 0
@stderr = global i32 0
@.str.1 = [21 x i8] c"Value is too small!\0A\00"
@HUGE_VAL = global double 0.000000e+00
@.str.2 = [19 x i8] c"upper overflowing\0A\00"
@.str.3 = [19 x i8] c"lower overflowing\0A\00"
@.str.4 = [13 x i8] c"'%s' ==> %g\0A\00"
define i32 @main(i32 %0, i8** nocapture %1) {
%3 = alloca i8*
%4 = bitcast i8** %3 to i8*
%5 = icmp slt i32 %0, 2
br i1 %5, label %8, label %6
6: ; preds = %2
%7 = zext i32 %0 to i64
br label %11
8: ; preds = %2
%9 = load i8*, i8** %1
%10 = tail call i32 (i8*, i8*, ...) @printf(i8* getelementptr inbounds ([44 x i8], [44 x i8]* @.str, i64 0, i64 0), i8* %9)
br label %49
11: ; preds = %6, %44
%12 = phi i64 [ 1, %6 ], [ %47, %44 ]
store i64 0, i64* @errno
%13 = getelementptr inbounds i8*, i8** %1, i64 %12
%14 = load i8*, i8** %13
%15 = call double @strtod(i8* %14, i8** %3)
%16 = fcmp oeq double %15, 0.000000e+00
br i1 %16, label %17, label %24
17: ; preds = %11
%18 = load i64, i64* @errno
%19 = load i64, i64* @ERANGE
%20 = icmp eq i64 %18, %19
br i1 %20, label %21, label %44
21: ; preds = %17
%22 = load i32, i32* @stderr
%23 = tail call i32 @fprintf(i32 %22, i8* getelementptr inbounds ([21 x i8], [21 x i8]* @.str.1, i64 0, i64 0))
br label %49
24: ; preds = %11
%25 = load double, double* @HUGE_VAL
%26 = fcmp oeq double %15, %25
br i1 %26, label %27, label %34
27: ; preds = %24
%28 = load i64, i64* @errno
%29 = load i64, i64* @ERANGE
%30 = icmp eq i64 %28, %29
br i1 %30, label %31, label %44
31: ; preds = %27
%32 = load i32, i32* @stderr
%33 = tail call i32 @fprintf(i32 %32, i8* getelementptr inbounds ([19 x i8], [19 x i8]* @.str.2, i64 0, i64 0))
br label %49
34: ; preds = %24
%35 = fneg double %25
%36 = fcmp oeq double %15, %35
br i1 %36, label %37, label %44
37: ; preds = %34
%38 = load i64, i64* @errno
%39 = load i64, i64* @ERANGE
%40 = icmp eq i64 %38, %39
br i1 %40, label %41, label %44
41: ; preds = %37
%42 = load i32, i32* @stderr
%43 = tail call i32 @fprintf(i32 %42, i8* getelementptr inbounds ([19 x i8], [19 x i8]* @.str.3, i64 0, i64 0))
br label %49
44: ; preds = %27, %37, %34, %17
%45 = load i8*, i8** %13
%46 = tail call i32 (i8*, i8*, ...) @printf(i8* getelementptr inbounds ([13 x i8], [13 x i8]* @.str.4, i64 0, i64 0), i8* %45, double %15)
%47 = add nuw nsw i64 %12, 1
%48 = icmp eq i64 %47, %7
br i1 %48, label %49, label %11
49: ; preds = %44, %41, %31, %21, %8
%50 = phi i32 [ 0, %8 ], [ 1, %21 ], [ 1, %31 ], [ 1, %41 ], [ 0, %44 ]
ret i32 %50
}