#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 */
double log(int);
int /*<<< orphan*/ printf(char *, ...);
int /*<<< orphan*/ sprintf(char *, char *, double);
int main() {
  int x = 320000;
  char s[100];
  int i;
  sprintf(s, "%.5f", log(x) / log(2));
  printf("x = [");
  for (i = 0; s[i] != '.'; ++i)
    printf("%c", s[i]);
  printf("]\n");
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x90,%rsp
movl   $0x0,-0x4(%rbp)
movl   $0x4e200,-0x8(%rbp)
lea    -0x70(%rbp),%rax
mov    %rax,-0x88(%rbp)
mov    -0x8(%rbp),%edi
call   1040 <log@plt>
movsd  %xmm0,-0x80(%rbp)
mov    $0x2,%edi
call   1040 <log@plt>
mov    -0x88(%rbp),%rdi
movaps %xmm0,%xmm1
movsd  -0x80(%rbp),%xmm0
divsd  %xmm1,%xmm0
lea    0xe7b(%rip),%rsi
call   1050 <sprintf@plt>
lea    0xe74(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
movl   $0x0,-0x74(%rbp)
movslq -0x74(%rbp),%rax
movsbl -0x70(%rbp,%rax,1),%eax
cmp    $0x2e,%eax
je     11d6 <main+0xa6>
movslq -0x74(%rbp),%rax
movsbl -0x70(%rbp,%rax,1),%esi
lea    0xe4a(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
mov    -0x74(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x74(%rbp)
jmp    119f <main+0x6f>
lea    0xe31(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
xor    %eax,%eax
add    $0x90,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbx
sub    $0x80,%rsp
mov    $0x4e200,%edi
call   1060 <log@plt>
movsd  %xmm0,0x8(%rsp)
mov    $0x2,%edi
call   1060 <log@plt>
movsd  0x8(%rsp),%xmm1
divsd  %xmm0,%xmm1
lea    0xe7d(%rip),%rsi
lea    0x10(%rsp),%rdi
movapd %xmm1,%xmm0
call   1070 <sprintf@plt>
lea    0xe6d(%rip),%rdi
xor    %eax,%eax
call   1050 <printf@plt>
mov    0x10(%rsp),%al
cmp    $0x2e,%al
je     11c3 <main+0x73>
lea    0x11(%rsp),%rbx
nopl   0x0(%rax)
movsbl %al,%edi
call   1030 <putchar@plt>
movzbl (%rbx),%eax
add    $0x1,%rbx
cmp    $0x2e,%al
jne    11b0 <main+0x60>
lea    0xe41(%rip),%rdi
call   1040 <puts@plt>
xor    %eax,%eax
add    $0x80,%rsp
pop    %rbx
ret

LLVM IR (-O0):
@.str = [5 x i8] c"%.5f\00"
@.str.1 = [6 x i8] c"x = [\00"
@.str.2 = [3 x i8] c"%c\00"
@.str.3 = [3 x i8] c"]\0A\00"
define i32 @main() {
%1 = alloca i32
%2 = alloca i32
%3 = alloca [100 x i8]
%4 = alloca i32
store i32 0, i32* %1
store i32 320000, i32* %2
%5 = getelementptr inbounds [100 x i8], [100 x i8]* %3, i64 0, i64 0
%6 = load i32, i32* %2
%7 = call double @log(i32 %6)
%8 = call double @log(i32 2)
%9 = fdiv double %7, %8
%10 = call i32 @sprintf(i8* %5, i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str, i64 0, i64 0), double %9)
%11 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.1, i64 0, i64 0))
store i32 0, i32* %4
br label %12
12: ; preds = %26, %0
%13 = load i32, i32* %4
%14 = sext i32 %13 to i64
%15 = getelementptr inbounds [100 x i8], [100 x i8]* %3, i64 0, i64 %14
%16 = load i8, i8* %15
%17 = sext i8 %16 to i32
%18 = icmp ne i32 %17, 46
br i1 %18, label %19, label %29
19: ; preds = %12
%20 = load i32, i32* %4
%21 = sext i32 %20 to i64
%22 = getelementptr inbounds [100 x i8], [100 x i8]* %3, i64 0, i64 %21
%23 = load i8, i8* %22
%24 = sext i8 %23 to i32
%25 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.2, i64 0, i64 0), i32 %24)
br label %26
26: ; preds = %19
%27 = load i32, i32* %4
%28 = add nsw i32 %27, 1
store i32 %28, i32* %4
br label %12
29: ; preds = %12
%30 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.3, i64 0, i64 0))
ret i32 0
}

LLVM IR (-O2):
@.str = [5 x i8] c"%.5f\00"
@.str.1 = [6 x i8] c"x = [\00"
@str = [2 x i8] c"]\00"
define i32 @main() {
%1 = alloca [100 x i8]
%2 = getelementptr inbounds [100 x i8], [100 x i8]* %1, i64 0, i64 0
%3 = tail call double @log(i32 320000)
%4 = tail call double @log(i32 2)
%5 = fdiv double %3, %4
%6 = call i32 @sprintf(i8* %2, i8* dereferenceable(1) getelementptr inbounds ([5 x i8], [5 x i8]* @.str, i64 0, i64 0), double %5)
%7 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([6 x i8], [6 x i8]* @.str.1, i64 0, i64 0))
%8 = load i8, i8* %2
%9 = icmp eq i8 %8, 46
br i1 %9, label %19, label %10
10: ; preds = %0, %10
%11 = phi i64 [ %15, %10 ], [ 0, %0 ]
%12 = phi i8 [ %17, %10 ], [ %8, %0 ]
%13 = sext i8 %12 to i32
%14 = tail call i32 @putchar(i32 %13)
%15 = add nuw i64 %11, 1
%16 = getelementptr inbounds [100 x i8], [100 x i8]* %1, i64 0, i64 %15
%17 = load i8, i8* %16
%18 = icmp eq i8 %17, 46
br i1 %18, label %19, label %10
19: ; preds = %10, %0
%20 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([2 x i8], [2 x i8]* @str, i64 0, i64 0))
ret i32 0
}