#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*/ printf(char *, double);
int /*<<< orphan*/ sscanf(char *, char *, double *);
int main(int argc, char *argv[]) {
  double x;
  if (argc == 3) {
    sscanf(argv[2], "%la", &x);
    printf("%g\n", x);
  } else {
    sscanf(argv[1], "%lf", &x);
    printf("%a\n", x);
  }
}


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)
cmpl   $0x3,-0x8(%rbp)
jne    116e <main+0x4e>
mov    -0x10(%rbp),%rax
mov    0x10(%rax),%rdi
lea    0xeb1(%rip),%rsi
lea    -0x18(%rbp),%rdx
call   1040 <sscanf@plt>
movsd  -0x18(%rbp),%xmm0
lea    0xea0(%rip),%rdi
call   1030 <printf@plt>
jmp    1197 <main+0x77>
mov    -0x10(%rbp),%rax
mov    0x8(%rax),%rdi
lea    0xe8b(%rip),%rsi
lea    -0x18(%rbp),%rdx
call   1040 <sscanf@plt>
movsd  -0x18(%rbp),%xmm0
lea    0xe7a(%rip),%rdi
call   1030 <printf@plt>
mov    -0x4(%rbp),%eax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rax
cmp    $0x3,%edi
jne    1147 <main+0x27>
mov    0x10(%rsi),%rdi
lea    0xecf(%rip),%rsi
mov    %rsp,%rdx
call   1040 <sscanf@plt>
movsd  (%rsp),%xmm0
lea    0xebf(%rip),%rdi
jmp    1166 <main+0x46>
mov    0x8(%rsi),%rdi
lea    0xeb6(%rip),%rsi
mov    %rsp,%rdx
call   1040 <sscanf@plt>
movsd  (%rsp),%xmm0
lea    0xea6(%rip),%rdi
call   1030 <printf@plt>
xor    %eax,%eax
pop    %rcx
ret

LLVM IR (-O0):
@.str = [4 x i8] c"%la\00"
@.str.1 = [4 x i8] c"%g\0A\00"
@.str.2 = [4 x i8] c"%lf\00"
@.str.3 = [4 x i8] c"%a\0A\00"
define i32 @main(i32 %0, i8** %1) {
%3 = alloca i32
%4 = alloca i32
%5 = alloca i8**
%6 = alloca double
store i32 0, i32* %3
store i32 %0, i32* %4
store i8** %1, i8*** %5
%7 = load i32, i32* %4
%8 = icmp eq i32 %7, 3
br i1 %8, label %9, label %16
9: ; preds = %2
%10 = load i8**, i8*** %5
%11 = getelementptr inbounds i8*, i8** %10, i64 2
%12 = load i8*, i8** %11
%13 = call i32 @sscanf(i8* %12, i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str, i64 0, i64 0), double* %6)
%14 = load double, double* %6
%15 = call i32 @printf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.1, i64 0, i64 0), double %14)
br label %23
16: ; preds = %2
%17 = load i8**, i8*** %5
%18 = getelementptr inbounds i8*, i8** %17, i64 1
%19 = load i8*, i8** %18
%20 = call i32 @sscanf(i8* %19, i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.2, i64 0, i64 0), double* %6)
%21 = load double, double* %6
%22 = call i32 @printf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.3, i64 0, i64 0), double %21)
br label %23
23: ; preds = %16, %9
%24 = load i32, i32* %3
ret i32 %24
}

LLVM IR (-O2):
@.str = [4 x i8] c"%la\00"
@.str.1 = [4 x i8] c"%g\0A\00"
@.str.2 = [4 x i8] c"%lf\00"
@.str.3 = [4 x i8] c"%a\0A\00"
define i32 @main(i32 %0, i8** nocapture %1) {
%3 = alloca double
%4 = bitcast double* %3 to i8*
%5 = icmp eq i32 %0, 3
br i1 %5, label %6, label %12
6: ; preds = %2
%7 = getelementptr inbounds i8*, i8** %1, i64 2
%8 = load i8*, i8** %7
%9 = call i32 @sscanf(i8* %8, i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str, i64 0, i64 0), double* %3)
%10 = load double, double* %3
%11 = call i32 @printf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.1, i64 0, i64 0), double %10)
br label %18
12: ; preds = %2
%13 = getelementptr inbounds i8*, i8** %1, i64 1
%14 = load i8*, i8** %13
%15 = call i32 @sscanf(i8* %14, i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.2, i64 0, i64 0), double* %3)
%16 = load double, double* %3
%17 = call i32 @printf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.3, i64 0, i64 0), double %16)
br label %18
18: ; preds = %12, %6
ret i32 0
}