#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 *, char *, char *);
int /*<<< orphan*/ sprintf(char *, char *, int, int, unsigned long, double, int,
                           int, int, int, double, double, char const *, int,
                           int, int);
scalar_t__ strcmp(char *, char *);
void rfg3(void) {
  char buf[100];
  double g = 5.0000001;
  unsigned long l = 1234567890;
  double d = 321.7654321;
  const char s[] = "test-string";
  int i = 12345;
  int h = 1234;
  sprintf(buf, "%1$*5$d %2$*6$hi %3$*7$lo %4$*8$f %9$*12$e %10$*13$g %11$*14$s",
          i, h, l, d, 8, 5, 14, 14, d, g, s, 14, 3, 14);
  if (strcmp(buf, "   12345  1234    11145401322     321.765432   3.217654e+02 "
                  "  5    test-string") != 0)
    printf("got: '%s', expected: '%s'\n", buf,
           "   12345  1234    11145401322     321.765432   3.217654e+02   5    "
           "test-string");
}


x86 assembly (clang, -O0):
<rfg3>:
push   %rbp
mov    %rsp,%rbp
sub    $0xe0,%rsp
movsd  0xec5(%rip),%xmm0
movsd  %xmm0,-0x78(%rbp)
movq   $0x499602d2,-0x80(%rbp)
49
movsd  0xea8(%rip),%xmm0
movsd  %xmm0,-0x88(%rbp)
ff
mov    0xf2b(%rip),%rax
mov    %rax,-0x94(%rbp)
mov    0xf26(%rip),%eax
mov    %eax,-0x8c(%rbp)
movl   $0x3039,-0x98(%rbp)
movl   $0x4d2,-0x9c(%rbp)
lea    -0x70(%rbp),%rdi
mov    -0x98(%rbp),%edx
mov    -0x9c(%rbp),%ecx
mov    -0x80(%rbp),%r8
movsd  -0x88(%rbp),%xmm0
ff
movsd  -0x88(%rbp),%xmm1
ff
movsd  -0x78(%rbp),%xmm2
lea    -0x94(%rbp),%rax
lea    0xe4b(%rip),%rsi
mov    $0x8,%r9d
movl   $0x5,(%rsp)
movl   $0xe,0x8(%rsp)
movl   $0xe,0x10(%rsp)
mov    %rax,0x18(%rsp)
movl   $0xe,0x20(%rsp)
movl   $0x3,0x28(%rsp)
movl   $0xe,0x30(%rsp)
call   1050 <sprintf@plt>
lea    -0x70(%rbp),%rdi
lea    0xe40(%rip),%rsi
call   1040 <strcmp@plt>
cmp    $0x0,%rax
je     1235 <rfg3+0x105>
lea    -0x70(%rbp),%rsi
lea    0xe75(%rip),%rdi
lea    0xe1f(%rip),%rdx
call   1030 <printf@plt>
add    $0xe0,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<rfg3>:
push   %rbx
sub    $0x80,%rsp
movabs $0x7274732d74736574,%rax
73 74 72
mov    %rax,(%rsp)
movl   $0x676e69,0x8(%rsp)
sub    $0x8,%rsp
lea    0x8(%rsp),%rax
lea    0xeb2(%rip),%rsi
lea    0x18(%rsp),%rbx
movsd  0xe95(%rip),%xmm0
movsd  0xe95(%rip),%xmm2
mov    $0x499602d2,%r8d
mov    %rbx,%rdi
mov    $0x3039,%edx
mov    $0x4d2,%ecx
mov    $0x8,%r9d
movaps %xmm0,%xmm1
push   $0xe
push   $0x3
push   $0xe
push   %rax
push   $0xe
push   $0xe
push   $0x5
call   1050 <sprintf@plt>
add    $0x40,%rsp
lea    0xea3(%rip),%rsi
mov    %rbx,%rdi
call   1040 <strcmp@plt>
test   %rax,%rax
je     11d1 <rfg3+0xa1>
lea    0xede(%rip),%rdi
lea    0xe88(%rip),%rdx
lea    0x10(%rsp),%rsi
call   1030 <printf@plt>
add    $0x80,%rsp
pop    %rbx
ret

LLVM IR (-O0):
@__const.rfg3.s = [12 x i8] c"test-string\00"
@.str = [63 x i8] c"%1$*5$d %2$*6$hi %3$*7$lo %4$*8$f %9$*12$e %10$*13$g %11$*14$s\00"
@.str.1 = [79 x i8] c" 12345 1234 11145401322 321.765432 3.217654e+02 5 test-string\00"
@.str.2 = [27 x i8] c"got: '%s', expected: '%s'\0A\00"
define void @rfg3() {
%1 = alloca [100 x i8]
%2 = alloca double
%3 = alloca i64
%4 = alloca double
%5 = alloca [12 x i8]
%6 = alloca i32
%7 = alloca i32
store double 0x4014000006B5FCA7, double* %2
store i64 1234567890, i64* %3
store double 0x40741C3F35BACCF0, double* %4
%8 = bitcast [12 x i8]* %5 to i8*
store i32 12345, i32* %6
store i32 1234, i32* %7
%9 = getelementptr inbounds [100 x i8], [100 x i8]* %1, i64 0, i64 0
%10 = load i32, i32* %6
%11 = load i32, i32* %7
%12 = load i64, i64* %3
%13 = load double, double* %4
%14 = load double, double* %4
%15 = load double, double* %2
%16 = getelementptr inbounds [12 x i8], [12 x i8]* %5, i64 0, i64 0
%17 = call i32 @sprintf(i8* %9, i8* getelementptr inbounds ([63 x i8], [63 x i8]* @.str, i64 0, i64 0), i32 %10, i32 %11, i64 %12, double %13, i32 8, i32 5, i32 14, i32 14, double %14, double %15, i8* %16, i32 14, i32 3, i32 14)
%18 = getelementptr inbounds [100 x i8], [100 x i8]* %1, i64 0, i64 0
%19 = call i64 @strcmp(i8* %18, i8* getelementptr inbounds ([79 x i8], [79 x i8]* @.str.1, i64 0, i64 0))
%20 = icmp ne i64 %19, 0
br i1 %20, label %21, label %24
21: ; preds = %0
%22 = getelementptr inbounds [100 x i8], [100 x i8]* %1, i64 0, i64 0
%23 = call i32 @printf(i8* getelementptr inbounds ([27 x i8], [27 x i8]* @.str.2, i64 0, i64 0), i8* %22, i8* getelementptr inbounds ([79 x i8], [79 x i8]* @.str.1, i64 0, i64 0))
br label %24
24: ; preds = %21, %0
ret void
}

LLVM IR (-O2):
@__const.rfg3.s = [12 x i8] c"test-string\00"
@.str = [63 x i8] c"%1$*5$d %2$*6$hi %3$*7$lo %4$*8$f %9$*12$e %10$*13$g %11$*14$s\00"
@.str.1 = [79 x i8] c" 12345 1234 11145401322 321.765432 3.217654e+02 5 test-string\00"
@.str.2 = [27 x i8] c"got: '%s', expected: '%s'\0A\00"
define void @rfg3() {
%1 = alloca [100 x i8]
%2 = alloca [12 x i8]
%3 = getelementptr inbounds [100 x i8], [100 x i8]* %1, i64 0, i64 0
%4 = getelementptr inbounds [12 x i8], [12 x i8]* %2, i64 0, i64 0
%5 = call i32 @sprintf(i8* %3, i8* dereferenceable(1) getelementptr inbounds ([63 x i8], [63 x i8]* @.str, i64 0, i64 0), i32 12345, i32 1234, i64 1234567890, double 0x40741C3F35BACCF0, i32 8, i32 5, i32 14, i32 14, double 0x40741C3F35BACCF0, double 0x4014000006B5FCA7, i8* %4, i32 14, i32 3, i32 14)
%6 = call i64 @strcmp(i8* %3, i8* getelementptr inbounds ([79 x i8], [79 x i8]* @.str.1, i64 0, i64 0))
%7 = icmp eq i64 %6, 0
br i1 %7, label %10, label %8
8: ; preds = %0
%9 = call i32 @printf(i8* getelementptr inbounds ([27 x i8], [27 x i8]* @.str.2, i64 0, i64 0), i8* %3, i8* getelementptr inbounds ([79 x i8], [79 x i8]* @.str.1, i64 0, i64 0))
br label %10
10: ; preds = %8, %0
ret void
}