#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 atoi(char *);
int /*<<< orphan*/ printf(char *, float);
int /*<<< orphan*/ sscanf(char *, char *, int *, float *);
int main() {
  char *myStr = "582";
  char *myStr2 = "582 is my favorite number";
  char *myStr3 = "I like 639";
  char *str = "For 5 eggs it costs $8.94";
  int eggCount;
  float cost;
  int i = atoi(myStr);
  int i2 = atoi(myStr2);
  int i3 = atoi(myStr3);
  int i4 = atoi(&myStr3[7]);
  printf("%i\n", i);
  printf("%i\n", i2);
  printf("%i\n", i3);
  printf("%i\n", i4);
  sscanf(str, "for %i eggs it costs $%f", &eggCount, &cost);
  printf("For one egg it costs %.2f.\n", (float)eggCount / cost);
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x40,%rsp
movl   $0x0,-0x4(%rbp)
lea    0xeba(%rip),%rax
mov    %rax,-0x10(%rbp)
lea    0xeb3(%rip),%rax
mov    %rax,-0x18(%rbp)
lea    0xec2(%rip),%rax
mov    %rax,-0x20(%rbp)
lea    0xec2(%rip),%rax
mov    %rax,-0x28(%rbp)
mov    -0x10(%rbp),%rdi
call   1050 <atoi@plt>
mov    %eax,-0x34(%rbp)
mov    -0x18(%rbp),%rdi
call   1050 <atoi@plt>
mov    %eax,-0x38(%rbp)
mov    -0x20(%rbp),%rdi
call   1050 <atoi@plt>
mov    %eax,-0x3c(%rbp)
mov    -0x20(%rbp),%rdi
add    $0x7,%rdi
call   1050 <atoi@plt>
mov    %eax,-0x40(%rbp)
cvtsi2ssl -0x34(%rbp),%xmm0
lea    0xe98(%rip),%rdi
call   1030 <printf@plt>
cvtsi2ssl -0x38(%rbp),%xmm0
lea    0xe87(%rip),%rdi
call   1030 <printf@plt>
cvtsi2ssl -0x3c(%rbp),%xmm0
lea    0xe76(%rip),%rdi
call   1030 <printf@plt>
cvtsi2ssl -0x40(%rbp),%xmm0
lea    0xe65(%rip),%rdi
call   1030 <printf@plt>
mov    -0x28(%rbp),%rdi
lea    0xe59(%rip),%rsi
lea    -0x2c(%rbp),%rdx
lea    -0x30(%rbp),%rcx
call   1040 <sscanf@plt>
cvtsi2ssl -0x2c(%rbp),%xmm0
divss  -0x30(%rbp),%xmm0
lea    0xe54(%rip),%rdi
call   1030 <printf@plt>
xor    %eax,%eax
add    $0x40,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbp
push   %r14
push   %rbx
sub    $0x10,%rsp
lea    0xec9(%rip),%rdi
call   1050 <atoi@plt>
mov    %eax,%r14d
lea    0xed4(%rip),%rdi
call   1050 <atoi@plt>
mov    %eax,%ebp
lea    0xeeb(%rip),%rbx
movss  0xe9c(%rip),%xmm0
mov    %rbx,%rdi
call   1030 <printf@plt>
xorps  %xmm0,%xmm0
cvtsi2ss %r14d,%xmm0
mov    %rbx,%rdi
call   1030 <printf@plt>
xorps  %xmm0,%xmm0
cvtsi2ss %ebp,%xmm0
mov    %rbx,%rdi
call   1030 <printf@plt>
movss  0xe71(%rip),%xmm0
mov    %rbx,%rdi
call   1030 <printf@plt>
lea    0xe8b(%rip),%rdi
lea    0xea2(%rip),%rsi
lea    0xc(%rsp),%rdx
lea    0x8(%rsp),%rcx
call   1040 <sscanf@plt>
xorps  %xmm0,%xmm0
cvtsi2ssl 0xc(%rsp),%xmm0
divss  0x8(%rsp),%xmm0
lea    0xe96(%rip),%rdi
call   1030 <printf@plt>
xor    %eax,%eax
add    $0x10,%rsp
pop    %rbx
pop    %r14
pop    %rbp
ret

LLVM IR (-O0):
@.str = [4 x i8] c"582\00"
@.str.1 = [26 x i8] c"582 is my favorite number\00"
@.str.2 = [11 x i8] c"I like 639\00"
@.str.3 = [26 x i8] c"For 5 eggs it costs $8.94\00"
@.str.4 = [4 x i8] c"%i\0A\00"
@.str.5 = [25 x i8] c"for %i eggs it costs $%f\00"
@.str.6 = [28 x i8] c"For one egg it costs %.2f.\0A\00"
define i32 @main() {
%1 = alloca i32
%2 = alloca i8*
%3 = alloca i8*
%4 = alloca i8*
%5 = alloca i8*
%6 = alloca i32
%7 = alloca float
%8 = alloca i32
%9 = alloca i32
%10 = alloca i32
%11 = alloca i32
store i32 0, i32* %1
store i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str, i64 0, i64 0), i8** %2
store i8* getelementptr inbounds ([26 x i8], [26 x i8]* @.str.1, i64 0, i64 0), i8** %3
store i8* getelementptr inbounds ([11 x i8], [11 x i8]* @.str.2, i64 0, i64 0), i8** %4
store i8* getelementptr inbounds ([26 x i8], [26 x i8]* @.str.3, i64 0, i64 0), i8** %5
%12 = load i8*, i8** %2
%13 = call i32 @atoi(i8* %12)
store i32 %13, i32* %8
%14 = load i8*, i8** %3
%15 = call i32 @atoi(i8* %14)
store i32 %15, i32* %9
%16 = load i8*, i8** %4
%17 = call i32 @atoi(i8* %16)
store i32 %17, i32* %10
%18 = load i8*, i8** %4
%19 = getelementptr inbounds i8, i8* %18, i64 7
%20 = call i32 @atoi(i8* %19)
store i32 %20, i32* %11
%21 = load i32, i32* %8
%22 = sitofp i32 %21 to float
%23 = call i32 @printf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.4, i64 0, i64 0), float %22)
%24 = load i32, i32* %9
%25 = sitofp i32 %24 to float
%26 = call i32 @printf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.4, i64 0, i64 0), float %25)
%27 = load i32, i32* %10
%28 = sitofp i32 %27 to float
%29 = call i32 @printf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.4, i64 0, i64 0), float %28)
%30 = load i32, i32* %11
%31 = sitofp i32 %30 to float
%32 = call i32 @printf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.4, i64 0, i64 0), float %31)
%33 = load i8*, i8** %5
%34 = call i32 @sscanf(i8* %33, i8* getelementptr inbounds ([25 x i8], [25 x i8]* @.str.5, i64 0, i64 0), i32* %6, float* %7)
%35 = load i32, i32* %6
%36 = sitofp i32 %35 to float
%37 = load float, float* %7
%38 = fdiv float %36, %37
%39 = call i32 @printf(i8* getelementptr inbounds ([28 x i8], [28 x i8]* @.str.6, i64 0, i64 0), float %38)
ret i32 0
}

LLVM IR (-O2):
@.str.1 = [26 x i8] c"582 is my favorite number\00"
@.str.2 = [11 x i8] c"I like 639\00"
@.str.3 = [26 x i8] c"For 5 eggs it costs $8.94\00"
@.str.4 = [4 x i8] c"%i\0A\00"
@.str.5 = [25 x i8] c"for %i eggs it costs $%f\00"
@.str.6 = [28 x i8] c"For one egg it costs %.2f.\0A\00"
define i32 @main() {
%1 = alloca i32
%2 = alloca float
%3 = bitcast i32* %1 to i8*
%4 = bitcast float* %2 to i8*
%5 = tail call i32 @atoi(i8* getelementptr inbounds ([26 x i8], [26 x i8]* @.str.1, i64 0, i64 0))
%6 = tail call i32 @atoi(i8* getelementptr inbounds ([11 x i8], [11 x i8]* @.str.2, i64 0, i64 0))
%7 = tail call i32 @printf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.4, i64 0, i64 0), float 5.820000e+02)
%8 = sitofp i32 %5 to float
%9 = tail call i32 @printf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.4, i64 0, i64 0), float %8)
%10 = sitofp i32 %6 to float
%11 = tail call i32 @printf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.4, i64 0, i64 0), float %10)
%12 = tail call i32 @printf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.4, i64 0, i64 0), float 6.390000e+02)
%13 = call i32 @sscanf(i8* getelementptr inbounds ([26 x i8], [26 x i8]* @.str.3, i64 0, i64 0), i8* getelementptr inbounds ([25 x i8], [25 x i8]* @.str.5, i64 0, i64 0), i32* %1, float* %2)
%14 = load i32, i32* %1
%15 = sitofp i32 %14 to float
%16 = load float, float* %2
%17 = fdiv float %15, %16
%18 = call i32 @printf(i8* getelementptr inbounds ([28 x i8], [28 x i8]* @.str.6, i64 0, i64 0), float %17)
ret i32 0
}