#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*/ exit(int);
int /*<<< orphan*/ printf(char *, ...);
int /*<<< orphan*/ sprintf(char *, char *, double);
int main() {
  char buffer[16];
  double d = 7.75;
  sprintf(buffer, "%5.2f", d);
  printf("The buffer is: %s\n", buffer);
  if (buffer[0] != ' ' || buffer[1] != '7' || buffer[2] != '.') {
    printf("Error %d\n", (int)1);
    exit(1);
  };
  {
    printf("Success\n");
    exit(0);
  };
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
movl   $0x0,-0x4(%rbp)
movsd  0xeb9(%rip),%xmm0
movsd  %xmm0,-0x28(%rbp)
lea    -0x20(%rbp),%rdi
movsd  -0x28(%rbp),%xmm0
lea    0xeac(%rip),%rsi
call   1040 <sprintf@plt>
lea    -0x20(%rbp),%rsi
lea    0xea2(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
movsbl -0x20(%rbp),%eax
cmp    $0x20,%eax
jne    119a <main+0x6a>
movsbl -0x1f(%rbp),%eax
cmp    $0x37,%eax
jne    119a <main+0x6a>
movsbl -0x1e(%rbp),%eax
cmp    $0x2e,%eax
je     11b7 <main+0x87>
lea    0xe80(%rip),%rdi
mov    $0x1,%esi
mov    $0x0,%al
call   1030 <printf@plt>
mov    $0x1,%edi
call   1050 <exit@plt>
lea    0xe6d(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
xor    %edi,%edi
call   1050 <exit@plt>

x86 assembly (clang, -O2):
<main>:
push   %rbx
sub    $0x10,%rsp
lea    0xebc(%rip),%rsi
mov    %rsp,%rbx
movsd  0xea9(%rip),%xmm0
mov    %rbx,%rdi
call   1050 <sprintf@plt>
lea    0xea8(%rip),%rdi
mov    %rbx,%rsi
xor    %eax,%eax
call   1040 <printf@plt>
cmpb   $0x20,(%rsp)
jne    1197 <main+0x57>
cmpb   $0x37,0x1(%rsp)
jne    1197 <main+0x57>
cmpb   $0x2e,0x2(%rsp)
jne    1197 <main+0x57>
lea    0xea0(%rip),%rdi
call   1030 <puts@plt>
xor    %edi,%edi
call   1060 <exit@plt>
lea    0xe83(%rip),%rdi
mov    $0x1,%esi
xor    %eax,%eax
call   1040 <printf@plt>
mov    $0x1,%edi
call   1060 <exit@plt>

LLVM IR (-O0):
@.str = [6 x i8] c"%5.2f\00"
@.str.1 = [19 x i8] c"The buffer is: %s\0A\00"
@.str.2 = [10 x i8] c"Error %d\0A\00"
@.str.3 = [9 x i8] c"Success\0A\00"
define i32 @main() {
%1 = alloca i32
%2 = alloca [16 x i8]
%3 = alloca double
store i32 0, i32* %1
store double 7.750000e+00, double* %3
%4 = getelementptr inbounds [16 x i8], [16 x i8]* %2, i64 0, i64 0
%5 = load double, double* %3
%6 = call i32 @sprintf(i8* %4, i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str, i64 0, i64 0), double %5)
%7 = getelementptr inbounds [16 x i8], [16 x i8]* %2, i64 0, i64 0
%8 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([19 x i8], [19 x i8]* @.str.1, i64 0, i64 0), i8* %7)
%9 = getelementptr inbounds [16 x i8], [16 x i8]* %2, i64 0, i64 0
%10 = load i8, i8* %9
%11 = sext i8 %10 to i32
%12 = icmp ne i32 %11, 32
br i1 %12, label %23, label %13
13: ; preds = %0
%14 = getelementptr inbounds [16 x i8], [16 x i8]* %2, i64 0, i64 1
%15 = load i8, i8* %14
%16 = sext i8 %15 to i32
%17 = icmp ne i32 %16, 55
br i1 %17, label %23, label %18
18: ; preds = %13
%19 = getelementptr inbounds [16 x i8], [16 x i8]* %2, i64 0, i64 2
%20 = load i8, i8* %19
%21 = sext i8 %20 to i32
%22 = icmp ne i32 %21, 46
br i1 %22, label %23, label %26
23: ; preds = %18, %13, %0
%24 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([10 x i8], [10 x i8]* @.str.2, i64 0, i64 0), i32 1)
%25 = call i32 @exit(i32 1)
unreachable
26: ; preds = %18
%27 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([9 x i8], [9 x i8]* @.str.3, i64 0, i64 0))
%28 = call i32 @exit(i32 0)
unreachable
}

LLVM IR (-O2):
@.str = [6 x i8] c"%5.2f\00"
@.str.1 = [19 x i8] c"The buffer is: %s\0A\00"
@.str.2 = [10 x i8] c"Error %d\0A\00"
@str = [8 x i8] c"Success\00"
define i32 @main() {
%1 = alloca [16 x i8]
%2 = getelementptr inbounds [16 x i8], [16 x i8]* %1, i64 0, i64 0
%3 = call i32 @sprintf(i8* %2, i8* dereferenceable(1) getelementptr inbounds ([6 x i8], [6 x i8]* @.str, i64 0, i64 0), double 7.750000e+00)
%4 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([19 x i8], [19 x i8]* @.str.1, i64 0, i64 0), i8* %2)
%5 = load i8, i8* %2
%6 = icmp ne i8 %5, 32
%7 = getelementptr inbounds [16 x i8], [16 x i8]* %1, i64 0, i64 1
%8 = load i8, i8* %7
%9 = icmp ne i8 %8, 55
%10 = select i1 %6, i1 true, i1 %9
%11 = getelementptr inbounds [16 x i8], [16 x i8]* %1, i64 0, i64 2
%12 = load i8, i8* %11
%13 = icmp ne i8 %12, 46
%14 = select i1 %10, i1 true, i1 %13
br i1 %14, label %15, label %18
15: ; preds = %0
%16 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([10 x i8], [10 x i8]* @.str.2, i64 0, i64 0), i32 1)
%17 = call i32 @exit(i32 1)
unreachable
18: ; preds = %0
%19 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([8 x i8], [8 x i8]* @str, i64 0, i64 0))
%20 = call i32 @exit(i32 0)
unreachable
}