#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*/ assert(int);
int /*<<< orphan*/ format_test(char *, char *, ...);
int int_len(int);
void test__simple(void) {
  format_test(NULL, "SET foo %c", 'c');
  format_test(NULL, "%c", 'c');
  format_test(NULL, "%c");
  format_test("*2\r\n$4\r\nPING\r\n$4\r\nPONG\r\n", "PING PONG");
  format_test("*3\r\n$3\r\nSET\r\n$3\r\nfoo\r\n$3\r\nbar\r\n", "SET foo %b",
              "bar", 3);
  format_test("*3\r\n$3\r\nSET\r\n$3\r\nbar\r\n$3\r\nfoo\r\n", "SET %b foo",
              "bar", 3);
  format_test("*3\r\n$3\r\nSET\r\n$3\r\nbar\r\n$3\r\nfoo\r\n",
              "  SET    %b   foo   ", "bar", 3);
  format_test("*2\r\n$3\r\nGET\r\n$3\r\nfoo\r\n", "GET %s", "foo");
  format_test("*6\r\n$3\r\nGET\r\n$1\r\na\r\n$1\r\nb\r\n$1\r\nc\r\n$1\r\nd\r\n$"
              "1\r\ne\r\n",
              "GET %b %b %b %b %b", "a", 1, "b", 1, "c", 1, "d", 1, "e", 1);
  assert(int_len(1) == 1);
  assert(int_len(9) == 1);
  assert(int_len(10) == 2);
  assert(int_len(199) == 3);
  assert(int_len(536870912) == 9);
}


x86 assembly (clang, -O0):
<test__simple>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
xor    %eax,%eax
mov    %eax,%edi
lea    0xebd(%rip),%rsi
mov    $0x63,%edx
mov    $0x0,%al
call   1040 <format_test@plt>
xor    %eax,%eax
mov    %eax,%edi
lea    0xeae(%rip),%rsi
mov    $0x63,%edx
mov    $0x0,%al
call   1040 <format_test@plt>
xor    %eax,%eax
mov    %eax,%edi
lea    0xe97(%rip),%rsi
mov    $0x0,%al
call   1040 <format_test@plt>
lea    0xe8c(%rip),%rdi
lea    0xe9e(%rip),%rsi
mov    $0x0,%al
call   1040 <format_test@plt>
lea    0xe9a(%rip),%rdi
lea    0xeb3(%rip),%rsi
lea    0xeb7(%rip),%rdx
mov    $0x3,%ecx
mov    $0x0,%al
call   1040 <format_test@plt>
lea    0xea8(%rip),%rdi
lea    0xec1(%rip),%rsi
lea    0xe96(%rip),%rdx
mov    $0x3,%ecx
mov    $0x0,%al
call   1040 <format_test@plt>
lea    0xe87(%rip),%rdi
lea    0xeab(%rip),%rsi
lea    0xe75(%rip),%rdx
mov    $0x3,%ecx
mov    $0x0,%al
call   1040 <format_test@plt>
lea    0xea6(%rip),%rdi
lea    0xeb6(%rip),%rsi
lea    0xe7f(%rip),%rdx
mov    $0x0,%al
call   1040 <format_test@plt>
lea    0xea8(%rip),%rdi
lea    0xed2(%rip),%rsi
lea    0xede(%rip),%rdx
mov    $0x1,%r9d
lea    0xecf(%rip),%r8
lea    0xdd4(%rip),%r11
lea    0xec5(%rip),%r10
lea    0xec0(%rip),%rax
mov    %r9d,%ecx
mov    %r11,(%rsp)
movl   $0x1,0x8(%rsp)
mov    %r10,0x10(%rsp)
movl   $0x1,0x18(%rsp)
mov    %rax,0x20(%rsp)
movl   $0x1,0x28(%rsp)
mov    $0x0,%al
call   1040 <format_test@plt>
mov    $0x1,%edi
call   1050 <int_len@plt>
cmp    $0x1,%eax
sete   %al
and    $0x1,%al
movzbl %al,%edi
call   1030 <assert@plt>
mov    $0x9,%edi
call   1050 <int_len@plt>
cmp    $0x1,%eax
sete   %al
and    $0x1,%al
movzbl %al,%edi
call   1030 <assert@plt>
mov    $0xa,%edi
call   1050 <int_len@plt>
cmp    $0x2,%eax
sete   %al
and    $0x1,%al
movzbl %al,%edi
call   1030 <assert@plt>
mov    $0xc7,%edi
call   1050 <int_len@plt>
cmp    $0x3,%eax
sete   %al
and    $0x1,%al
movzbl %al,%edi
call   1030 <assert@plt>
mov    $0x20000000,%edi
call   1050 <int_len@plt>
cmp    $0x9,%eax
sete   %al
and    $0x1,%al
movzbl %al,%edi
call   1030 <assert@plt>
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<test__simple>:
push   %r14
push   %rbx
push   %rax
lea    0xec5(%rip),%rsi
xor    %edi,%edi
mov    $0x63,%edx
xor    %eax,%eax
call   1040 <format_test@plt>
lea    0xeb8(%rip),%rbx
xor    %edi,%edi
mov    %rbx,%rsi
mov    $0x63,%edx
xor    %eax,%eax
call   1040 <format_test@plt>
xor    %edi,%edi
mov    %rbx,%rsi
xor    %eax,%eax
call   1040 <format_test@plt>
lea    0xe97(%rip),%rdi
lea    0xea9(%rip),%rsi
xor    %eax,%eax
call   1040 <format_test@plt>
lea    0xea5(%rip),%rdi
lea    0xebe(%rip),%rsi
lea    0xec2(%rip),%rbx
mov    %rbx,%rdx
mov    $0x3,%ecx
xor    %eax,%eax
call   1040 <format_test@plt>
lea    0xeb0(%rip),%r14
lea    0xec9(%rip),%rsi
mov    %r14,%rdi
mov    %rbx,%rdx
mov    $0x3,%ecx
xor    %eax,%eax
call   1040 <format_test@plt>
lea    0xebb(%rip),%rsi
mov    %r14,%rdi
mov    %rbx,%rdx
mov    $0x3,%ecx
xor    %eax,%eax
call   1040 <format_test@plt>
lea    0xeb7(%rip),%rdi
lea    0xec7(%rip),%rsi
lea    0xe90(%rip),%rdx
xor    %eax,%eax
call   1040 <format_test@plt>
lea    0xf01(%rip),%rbx
lea    0xef8(%rip),%r10
lea    0xdf9(%rip),%r11
lea    0xea4(%rip),%rdi
lea    0xece(%rip),%rsi
lea    0xeda(%rip),%rdx
lea    0xed1(%rip),%r8
mov    $0x1,%ecx
mov    $0x1,%r9d
mov    $0x0,%eax
push   $0x1
push   %rbx
push   $0x1
push   %r10
push   $0x1
push   %r11
call   1040 <format_test@plt>
add    $0x30,%rsp
mov    $0x1,%edi
call   1050 <int_len@plt>
xor    %edi,%edi
cmp    $0x1,%eax
sete   %dil
call   1030 <assert@plt>
mov    $0x9,%edi
call   1050 <int_len@plt>
xor    %edi,%edi
cmp    $0x1,%eax
sete   %dil
call   1030 <assert@plt>
mov    $0xa,%edi
call   1050 <int_len@plt>
xor    %edi,%edi
cmp    $0x2,%eax
sete   %dil
call   1030 <assert@plt>
mov    $0xc7,%edi
call   1050 <int_len@plt>
xor    %edi,%edi
cmp    $0x3,%eax
sete   %dil
call   1030 <assert@plt>
mov    $0x20000000,%edi
call   1050 <int_len@plt>
xor    %edi,%edi
cmp    $0x9,%eax
sete   %dil
add    $0x8,%rsp
pop    %rbx
pop    %r14
jmp    1030 <assert@plt>

LLVM IR (-O0):
@.str = [11 x i8] c"SET foo %c\00"
@.str.1 = [3 x i8] c"%c\00"
@.str.2 = [25 x i8] c"*2\0D\0A$4\0D\0APING\0D\0A$4\0D\0APONG\0D\0A\00"
@.str.3 = [10 x i8] c"PING PONG\00"
@.str.4 = [32 x i8] c"*3\0D\0A$3\0D\0ASET\0D\0A$3\0D\0Afoo\0D\0A$3\0D\0Abar\0D\0A\00"
@.str.5 = [11 x i8] c"SET foo %b\00"
@.str.6 = [4 x i8] c"bar\00"
@.str.7 = [32 x i8] c"*3\0D\0A$3\0D\0ASET\0D\0A$3\0D\0Abar\0D\0A$3\0D\0Afoo\0D\0A\00"
@.str.8 = [11 x i8] c"SET %b foo\00"
@.str.9 = [21 x i8] c" SET %b foo \00"
@.str.10 = [23 x i8] c"*2\0D\0A$3\0D\0AGET\0D\0A$3\0D\0Afoo\0D\0A\00"
@.str.11 = [7 x i8] c"GET %s\00"
@.str.12 = [4 x i8] c"foo\00"
@.str.13 = [49 x i8] c"*6\0D\0A$3\0D\0AGET\0D\0A$1\0D\0Aa\0D\0A$1\0D\0Ab\0D\0A$1\0D\0Ac\0D\0A$1\0D\0Ad\0D\0A$1\0D\0Ae\0D\0A\00"
@.str.14 = [19 x i8] c"GET %b %b %b %b %b\00"
@.str.15 = [2 x i8] c"a\00"
@.str.16 = [2 x i8] c"b\00"
@.str.17 = [2 x i8] c"c\00"
@.str.18 = [2 x i8] c"d\00"
@.str.19 = [2 x i8] c"e\00"
define void @test__simple() {
%1 = call i32 (i8*, i8*, ...) @format_test(i8* null, i8* getelementptr inbounds ([11 x i8], [11 x i8]* @.str, i64 0, i64 0), i32 99)
%2 = call i32 (i8*, i8*, ...) @format_test(i8* null, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0), i32 99)
%3 = call i32 (i8*, i8*, ...) @format_test(i8* null, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0))
%4 = call i32 (i8*, i8*, ...) @format_test(i8* getelementptr inbounds ([25 x i8], [25 x i8]* @.str.2, i64 0, i64 0), i8* getelementptr inbounds ([10 x i8], [10 x i8]* @.str.3, i64 0, i64 0))
%5 = call i32 (i8*, i8*, ...) @format_test(i8* getelementptr inbounds ([32 x i8], [32 x i8]* @.str.4, i64 0, i64 0), i8* getelementptr inbounds ([11 x i8], [11 x i8]* @.str.5, i64 0, i64 0), i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.6, i64 0, i64 0), i32 3)
%6 = call i32 (i8*, i8*, ...) @format_test(i8* getelementptr inbounds ([32 x i8], [32 x i8]* @.str.7, i64 0, i64 0), i8* getelementptr inbounds ([11 x i8], [11 x i8]* @.str.8, i64 0, i64 0), i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.6, i64 0, i64 0), i32 3)
%7 = call i32 (i8*, i8*, ...) @format_test(i8* getelementptr inbounds ([32 x i8], [32 x i8]* @.str.7, i64 0, i64 0), i8* getelementptr inbounds ([21 x i8], [21 x i8]* @.str.9, i64 0, i64 0), i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.6, i64 0, i64 0), i32 3)
%8 = call i32 (i8*, i8*, ...) @format_test(i8* getelementptr inbounds ([23 x i8], [23 x i8]* @.str.10, i64 0, i64 0), i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str.11, i64 0, i64 0), i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.12, i64 0, i64 0))
%9 = call i32 (i8*, i8*, ...) @format_test(i8* getelementptr inbounds ([49 x i8], [49 x i8]* @.str.13, i64 0, i64 0), i8* getelementptr inbounds ([19 x i8], [19 x i8]* @.str.14, i64 0, i64 0), i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.15, i64 0, i64 0), i32 1, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.16, i64 0, i64 0), i32 1, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.17, i64 0, i64 0), i32 1, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.18, i64 0, i64 0), i32 1, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.19, i64 0, i64 0), i32 1)
%10 = call i32 @int_len(i32 1)
%11 = icmp eq i32 %10, 1
%12 = zext i1 %11 to i32
%13 = call i32 @assert(i32 %12)
%14 = call i32 @int_len(i32 9)
%15 = icmp eq i32 %14, 1
%16 = zext i1 %15 to i32
%17 = call i32 @assert(i32 %16)
%18 = call i32 @int_len(i32 10)
%19 = icmp eq i32 %18, 2
%20 = zext i1 %19 to i32
%21 = call i32 @assert(i32 %20)
%22 = call i32 @int_len(i32 199)
%23 = icmp eq i32 %22, 3
%24 = zext i1 %23 to i32
%25 = call i32 @assert(i32 %24)
%26 = call i32 @int_len(i32 536870912)
%27 = icmp eq i32 %26, 9
%28 = zext i1 %27 to i32
%29 = call i32 @assert(i32 %28)
ret void
}

LLVM IR (-O2):
@.str = [11 x i8] c"SET foo %c\00"
@.str.1 = [3 x i8] c"%c\00"
@.str.2 = [25 x i8] c"*2\0D\0A$4\0D\0APING\0D\0A$4\0D\0APONG\0D\0A\00"
@.str.3 = [10 x i8] c"PING PONG\00"
@.str.4 = [32 x i8] c"*3\0D\0A$3\0D\0ASET\0D\0A$3\0D\0Afoo\0D\0A$3\0D\0Abar\0D\0A\00"
@.str.5 = [11 x i8] c"SET foo %b\00"
@.str.6 = [4 x i8] c"bar\00"
@.str.7 = [32 x i8] c"*3\0D\0A$3\0D\0ASET\0D\0A$3\0D\0Abar\0D\0A$3\0D\0Afoo\0D\0A\00"
@.str.8 = [11 x i8] c"SET %b foo\00"
@.str.9 = [21 x i8] c" SET %b foo \00"
@.str.10 = [23 x i8] c"*2\0D\0A$3\0D\0AGET\0D\0A$3\0D\0Afoo\0D\0A\00"
@.str.11 = [7 x i8] c"GET %s\00"
@.str.12 = [4 x i8] c"foo\00"
@.str.13 = [49 x i8] c"*6\0D\0A$3\0D\0AGET\0D\0A$1\0D\0Aa\0D\0A$1\0D\0Ab\0D\0A$1\0D\0Ac\0D\0A$1\0D\0Ad\0D\0A$1\0D\0Ae\0D\0A\00"
@.str.14 = [19 x i8] c"GET %b %b %b %b %b\00"
@.str.15 = [2 x i8] c"a\00"
@.str.16 = [2 x i8] c"b\00"
@.str.17 = [2 x i8] c"c\00"
@.str.18 = [2 x i8] c"d\00"
@.str.19 = [2 x i8] c"e\00"
define void @test__simple() {
%1 = tail call i32 (i8*, i8*, ...) @format_test(i8* null, i8* getelementptr inbounds ([11 x i8], [11 x i8]* @.str, i64 0, i64 0), i32 99)
%2 = tail call i32 (i8*, i8*, ...) @format_test(i8* null, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0), i32 99)
%3 = tail call i32 (i8*, i8*, ...) @format_test(i8* null, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0))
%4 = tail call i32 (i8*, i8*, ...) @format_test(i8* getelementptr inbounds ([25 x i8], [25 x i8]* @.str.2, i64 0, i64 0), i8* getelementptr inbounds ([10 x i8], [10 x i8]* @.str.3, i64 0, i64 0))
%5 = tail call i32 (i8*, i8*, ...) @format_test(i8* getelementptr inbounds ([32 x i8], [32 x i8]* @.str.4, i64 0, i64 0), i8* getelementptr inbounds ([11 x i8], [11 x i8]* @.str.5, i64 0, i64 0), i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.6, i64 0, i64 0), i32 3)
%6 = tail call i32 (i8*, i8*, ...) @format_test(i8* getelementptr inbounds ([32 x i8], [32 x i8]* @.str.7, i64 0, i64 0), i8* getelementptr inbounds ([11 x i8], [11 x i8]* @.str.8, i64 0, i64 0), i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.6, i64 0, i64 0), i32 3)
%7 = tail call i32 (i8*, i8*, ...) @format_test(i8* getelementptr inbounds ([32 x i8], [32 x i8]* @.str.7, i64 0, i64 0), i8* getelementptr inbounds ([21 x i8], [21 x i8]* @.str.9, i64 0, i64 0), i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.6, i64 0, i64 0), i32 3)
%8 = tail call i32 (i8*, i8*, ...) @format_test(i8* getelementptr inbounds ([23 x i8], [23 x i8]* @.str.10, i64 0, i64 0), i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str.11, i64 0, i64 0), i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.12, i64 0, i64 0))
%9 = tail call i32 (i8*, i8*, ...) @format_test(i8* getelementptr inbounds ([49 x i8], [49 x i8]* @.str.13, i64 0, i64 0), i8* getelementptr inbounds ([19 x i8], [19 x i8]* @.str.14, i64 0, i64 0), i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.15, i64 0, i64 0), i32 1, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.16, i64 0, i64 0), i32 1, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.17, i64 0, i64 0), i32 1, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.18, i64 0, i64 0), i32 1, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.19, i64 0, i64 0), i32 1)
%10 = tail call i32 @int_len(i32 1)
%11 = icmp eq i32 %10, 1
%12 = zext i1 %11 to i32
%13 = tail call i32 @assert(i32 %12)
%14 = tail call i32 @int_len(i32 9)
%15 = icmp eq i32 %14, 1
%16 = zext i1 %15 to i32
%17 = tail call i32 @assert(i32 %16)
%18 = tail call i32 @int_len(i32 10)
%19 = icmp eq i32 %18, 2
%20 = zext i1 %19 to i32
%21 = tail call i32 @assert(i32 %20)
%22 = tail call i32 @int_len(i32 199)
%23 = icmp eq i32 %22, 3
%24 = zext i1 %23 to i32
%25 = tail call i32 @assert(i32 %24)
%26 = tail call i32 @int_len(i32 536870912)
%27 = icmp eq i32 %26, 9
%28 = zext i1 %27 to i32
%29 = tail call i32 @assert(i32 %28)
ret void
}