#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 */
typedef char wchar_t;

/* Variables and functions */
int /*<<< orphan*/ printf(char *, char *, char *);
int /*<<< orphan*/ snprintf(char *, int, char *, char *, int /*<<< orphan*/);
scalar_t__ strcmp(char *, char *);
int /*<<< orphan*/ wcstof(char *, int /*<<< orphan*/ *);
int main(void) {
  int result = 0;
  char buf[100];
  wchar_t tmp[3];
  tmp[0] = '8';
  tmp[1] = '1';
  tmp[2] = 0;
  snprintf(buf, 100, "%S = %f", tmp, wcstof(tmp, NULL));
  printf("\"%s\" -> %s\n", buf,
         strcmp(buf, "81 = 81.000000") == 0 ? "okay" : "buggy");
  result |= strcmp(buf, "81 = 81.000000") != 0;
  return result;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x90,%rsp
movl   $0x0,-0x4(%rbp)
movl   $0x0,-0x8(%rbp)
movb   $0x38,-0x73(%rbp)
movb   $0x31,-0x72(%rbp)
movb   $0x0,-0x71(%rbp)
lea    -0x70(%rbp),%rax
mov    %rax,-0x90(%rbp)
lea    -0x73(%rbp),%rax
mov    %rax,-0x88(%rbp)
lea    -0x73(%rbp),%rdi
xor    %eax,%eax
mov    %eax,%esi
call   1030 <wcstof@plt>
mov    -0x90(%rbp),%rdi
mov    -0x88(%rbp),%rcx
mov    %eax,%r8d
mov    $0x64,%esi
lea    0xe5b(%rip),%rdx
call   1050 <snprintf@plt>
lea    -0x70(%rbp),%rax
mov    %rax,-0x80(%rbp)
lea    -0x70(%rbp),%rdi
lea    0xe57(%rip),%rsi
call   1060 <strcmp@plt>
mov    -0x80(%rbp),%rsi
mov    %rax,%rcx
lea    0xe58(%rip),%rdx
lea    0xe4c(%rip),%rax
cmp    $0x0,%rcx
cmove  %rax,%rdx
lea    0xe22(%rip),%rdi
call   1040 <printf@plt>
lea    -0x70(%rbp),%rdi
lea    0xe1e(%rip),%rsi
call   1060 <strcmp@plt>
cmp    $0x0,%rax
setne  %al
and    $0x1,%al
movzbl %al,%eax
or     -0x8(%rbp),%eax
mov    %eax,-0x8(%rbp)
mov    -0x8(%rbp),%eax
add    $0x90,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %r14
push   %rbx
sub    $0x78,%rsp
movw   $0x3138,0xd(%rsp)
movb   $0x0,0xf(%rsp)
lea    0xd(%rsp),%r14
mov    %r14,%rdi
xor    %esi,%esi
call   1030 <wcstof@plt>
lea    0xe97(%rip),%rdx
lea    0x10(%rsp),%rbx
mov    %rbx,%rdi
mov    $0x64,%esi
mov    %r14,%rcx
mov    %eax,%r8d
call   1050 <snprintf@plt>
lea    0xe8c(%rip),%r14
mov    %rbx,%rdi
mov    %r14,%rsi
call   1060 <strcmp@plt>
test   %rax,%rax
lea    0xe86(%rip),%rax
lea    0xe84(%rip),%rdx
cmove  %rax,%rdx
lea    0xe59(%rip),%rdi
mov    %rbx,%rsi
call   1040 <printf@plt>
mov    %rbx,%rdi
mov    %r14,%rsi
call   1060 <strcmp@plt>
xor    %ecx,%ecx
test   %rax,%rax
setne  %cl
mov    %ecx,%eax
add    $0x78,%rsp
pop    %rbx
pop    %r14
ret

LLVM IR (-O0):
@.str = [8 x i8] c"%S = %f\00"
@.str.1 = [12 x i8] c"\22%s\22 -> %s\0A\00"
@.str.2 = [15 x i8] c"81 = 81.000000\00"
@.str.3 = [5 x i8] c"okay\00"
@.str.4 = [6 x i8] c"buggy\00"
define i32 @main() {
%1 = alloca i32
%2 = alloca i32
%3 = alloca [100 x i8]
%4 = alloca [3 x i8]
store i32 0, i32* %1
store i32 0, i32* %2
%5 = getelementptr inbounds [3 x i8], [3 x i8]* %4, i64 0, i64 0
store i8 56, i8* %5
%6 = getelementptr inbounds [3 x i8], [3 x i8]* %4, i64 0, i64 1
store i8 49, i8* %6
%7 = getelementptr inbounds [3 x i8], [3 x i8]* %4, i64 0, i64 2
store i8 0, i8* %7
%8 = getelementptr inbounds [100 x i8], [100 x i8]* %3, i64 0, i64 0
%9 = getelementptr inbounds [3 x i8], [3 x i8]* %4, i64 0, i64 0
%10 = getelementptr inbounds [3 x i8], [3 x i8]* %4, i64 0, i64 0
%11 = call i32 @wcstof(i8* %10, i32* null)
%12 = call i32 @snprintf(i8* %8, i32 100, i8* getelementptr inbounds ([8 x i8], [8 x i8]* @.str, i64 0, i64 0), i8* %9, i32 %11)
%13 = getelementptr inbounds [100 x i8], [100 x i8]* %3, i64 0, i64 0
%14 = getelementptr inbounds [100 x i8], [100 x i8]* %3, i64 0, i64 0
%15 = call i64 @strcmp(i8* %14, i8* getelementptr inbounds ([15 x i8], [15 x i8]* @.str.2, i64 0, i64 0))
%16 = icmp eq i64 %15, 0
%17 = zext i1 %16 to i64
%18 = select i1 %16, i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.3, i64 0, i64 0), i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.4, i64 0, i64 0)
%19 = call i32 @printf(i8* getelementptr inbounds ([12 x i8], [12 x i8]* @.str.1, i64 0, i64 0), i8* %13, i8* %18)
%20 = getelementptr inbounds [100 x i8], [100 x i8]* %3, i64 0, i64 0
%21 = call i64 @strcmp(i8* %20, i8* getelementptr inbounds ([15 x i8], [15 x i8]* @.str.2, i64 0, i64 0))
%22 = icmp ne i64 %21, 0
%23 = zext i1 %22 to i32
%24 = load i32, i32* %2
%25 = or i32 %24, %23
store i32 %25, i32* %2
%26 = load i32, i32* %2
ret i32 %26
}

LLVM IR (-O2):
@.str = [8 x i8] c"%S = %f\00"
@.str.1 = [12 x i8] c"\22%s\22 -> %s\0A\00"
@.str.2 = [15 x i8] c"81 = 81.000000\00"
@.str.3 = [5 x i8] c"okay\00"
@.str.4 = [6 x i8] c"buggy\00"
define i32 @main() {
%1 = alloca [100 x i8]
%2 = alloca [3 x i8]
%3 = getelementptr inbounds [100 x i8], [100 x i8]* %1, i64 0, i64 0
%4 = getelementptr inbounds [3 x i8], [3 x i8]* %2, i64 0, i64 0
store i8 56, i8* %4
%5 = getelementptr inbounds [3 x i8], [3 x i8]* %2, i64 0, i64 1
store i8 49, i8* %5
%6 = getelementptr inbounds [3 x i8], [3 x i8]* %2, i64 0, i64 2
store i8 0, i8* %6
%7 = call i32 @wcstof(i8* %4, i32* null)
%8 = call i32 @snprintf(i8* %3, i32 100, i8* getelementptr inbounds ([8 x i8], [8 x i8]* @.str, i64 0, i64 0), i8* %4, i32 %7)
%9 = call i64 @strcmp(i8* %3, i8* getelementptr inbounds ([15 x i8], [15 x i8]* @.str.2, i64 0, i64 0))
%10 = icmp eq i64 %9, 0
%11 = select i1 %10, i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.3, i64 0, i64 0), i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.4, i64 0, i64 0)
%12 = call i32 @printf(i8* getelementptr inbounds ([12 x i8], [12 x i8]* @.str.1, i64 0, i64 0), i8* %3, i8* %11)
%13 = call i64 @strcmp(i8* %3, i8* getelementptr inbounds ([15 x i8], [15 x i8]* @.str.2, i64 0, i64 0))
%14 = icmp ne i64 %13, 0
%15 = zext i1 %14 to i32
ret i32 %15
}