#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*/ fexpect_string(char *, int, char *, int /*<<< orphan*/);
int /*<<< orphan*/ fmt(char *, ...);
void test_va_list() {
  fexpect_string("/scratch/repos/new/home/jordi_armengol_estape/c-scraper/"
                 "outputs/2022-01-22/02-19-57/repos/8l/8cc/refs/heads/master/"
                 "test/input/8cc/varargs.c",
                 56, "", fmt(""));
  ;
  fexpect_string("/scratch/repos/new/home/jordi_armengol_estape/c-scraper/"
                 "outputs/2022-01-22/02-19-57/repos/8l/8cc/refs/heads/master/"
                 "test/input/8cc/varargs.c",
                 57, "3", fmt("%d", 3));
  ;
  fexpect_string("/scratch/repos/new/home/jordi_armengol_estape/c-scraper/"
                 "outputs/2022-01-22/02-19-57/repos/8l/8cc/refs/heads/master/"
                 "test/input/8cc/varargs.c",
                 58, "3,1.0,6,2.0,abc",
                 fmt("%d,%.1f,%d,%.1f,%s", 3, 1.0, 6, 2.0, "abc"));
  ;
}


x86 assembly (clang, -O0):
<test_va_list>:
push   %rbp
mov    %rsp,%rbp
lea    0xf72(%rip),%rdi
mov    $0x0,%al
call   1030 <fmt@plt>
mov    %eax,%ecx
lea    0xed5(%rip),%rdi
mov    $0x38,%esi
lea    0xf56(%rip),%rdx
call   1040 <fexpect_string@plt>
lea    0xf4b(%rip),%rdi
mov    $0x3,%esi
mov    $0x0,%al
call   1030 <fmt@plt>
mov    %eax,%ecx
lea    0xea8(%rip),%rdi
mov    $0x39,%esi
lea    0xf28(%rip),%rdx
call   1040 <fexpect_string@plt>
lea    0xf31(%rip),%rdi
mov    $0x3,%esi
movsd  0xe73(%rip),%xmm0
mov    $0x6,%edx
movsd  0xe6e(%rip),%xmm1
lea    0xf0c(%rip),%rcx
mov    $0x2,%al
call   1030 <fmt@plt>
mov    %eax,%ecx
lea    0xe5f(%rip),%rdi
mov    $0x3a,%esi
lea    0xee4(%rip),%rdx
call   1040 <fexpect_string@plt>
pop    %rbp
ret

x86 assembly (clang, -O2):
<test_va_list>:
push   %r14
push   %rbx
push   %rax
lea    0xf72(%rip),%rbx
mov    %rbx,%rdi
xor    %eax,%eax
call   1030 <fmt@plt>
lea    0xed4(%rip),%r14
mov    %r14,%rdi
mov    $0x38,%esi
mov    %rbx,%rdx
mov    %eax,%ecx
call   1040 <fexpect_string@plt>
lea    0xf49(%rip),%rdi
mov    $0x3,%esi
xor    %eax,%eax
call   1030 <fmt@plt>
lea    0xf34(%rip),%rdx
mov    %r14,%rdi
mov    $0x39,%esi
mov    %eax,%ecx
call   1040 <fexpect_string@plt>
lea    0xf33(%rip),%rdi
lea    0xf28(%rip),%rcx
movsd  0xe73(%rip),%xmm0
movsd  0xe73(%rip),%xmm1
mov    $0x3,%esi
mov    $0x6,%edx
mov    $0x2,%al
call   1030 <fmt@plt>
lea    0xef4(%rip),%rdx
mov    %r14,%rdi
mov    $0x3a,%esi
mov    %eax,%ecx
add    $0x8,%rsp
pop    %rbx
pop    %r14
jmp    1040 <fexpect_string@plt>

LLVM IR (-O0):
@.str = [140 x i8] c"/scratch/repos/new/home/jordi_armengol_estape/c-scraper/outputs/2022-01-22/02-19-57/repos/8l/8cc/refs/heads/master/test/input/8cc/varargs.c\00"
@.str.1 = [1 x i8] zeroinitializer
@.str.2 = [2 x i8] c"3\00"
@.str.3 = [3 x i8] c"%d\00"
@.str.4 = [16 x i8] c"3,1.0,6,2.0,abc\00"
@.str.5 = [19 x i8] c"%d,%.1f,%d,%.1f,%s\00"
@.str.6 = [4 x i8] c"abc\00"
define void @test_va_list() {
%1 = call i32 (i8*, ...) @fmt(i8* getelementptr inbounds ([1 x i8], [1 x i8]* @.str.1, i64 0, i64 0))
%2 = call i32 @fexpect_string(i8* getelementptr inbounds ([140 x i8], [140 x i8]* @.str, i64 0, i64 0), i32 56, i8* getelementptr inbounds ([1 x i8], [1 x i8]* @.str.1, i64 0, i64 0), i32 %1)
%3 = call i32 (i8*, ...) @fmt(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.3, i64 0, i64 0), i32 3)
%4 = call i32 @fexpect_string(i8* getelementptr inbounds ([140 x i8], [140 x i8]* @.str, i64 0, i64 0), i32 57, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.2, i64 0, i64 0), i32 %3)
%5 = call i32 (i8*, ...) @fmt(i8* getelementptr inbounds ([19 x i8], [19 x i8]* @.str.5, i64 0, i64 0), i32 3, double 1.000000e+00, i32 6, double 2.000000e+00, i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.6, i64 0, i64 0))
%6 = call i32 @fexpect_string(i8* getelementptr inbounds ([140 x i8], [140 x i8]* @.str, i64 0, i64 0), i32 58, i8* getelementptr inbounds ([16 x i8], [16 x i8]* @.str.4, i64 0, i64 0), i32 %5)
ret void
}

LLVM IR (-O2):
@.str = [140 x i8] c"/scratch/repos/new/home/jordi_armengol_estape/c-scraper/outputs/2022-01-22/02-19-57/repos/8l/8cc/refs/heads/master/test/input/8cc/varargs.c\00"
@.str.1 = [1 x i8] zeroinitializer
@.str.2 = [2 x i8] c"3\00"
@.str.3 = [3 x i8] c"%d\00"
@.str.4 = [16 x i8] c"3,1.0,6,2.0,abc\00"
@.str.5 = [19 x i8] c"%d,%.1f,%d,%.1f,%s\00"
@.str.6 = [4 x i8] c"abc\00"
define void @test_va_list() {
%1 = tail call i32 (i8*, ...) @fmt(i8* getelementptr inbounds ([1 x i8], [1 x i8]* @.str.1, i64 0, i64 0))
%2 = tail call i32 @fexpect_string(i8* getelementptr inbounds ([140 x i8], [140 x i8]* @.str, i64 0, i64 0), i32 56, i8* getelementptr inbounds ([1 x i8], [1 x i8]* @.str.1, i64 0, i64 0), i32 %1)
%3 = tail call i32 (i8*, ...) @fmt(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.3, i64 0, i64 0), i32 3)
%4 = tail call i32 @fexpect_string(i8* getelementptr inbounds ([140 x i8], [140 x i8]* @.str, i64 0, i64 0), i32 57, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.2, i64 0, i64 0), i32 %3)
%5 = tail call i32 (i8*, ...) @fmt(i8* getelementptr inbounds ([19 x i8], [19 x i8]* @.str.5, i64 0, i64 0), i32 3, double 1.000000e+00, i32 6, double 2.000000e+00, i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.6, i64 0, i64 0))
%6 = tail call i32 @fexpect_string(i8* getelementptr inbounds ([140 x i8], [140 x i8]* @.str, i64 0, i64 0), i32 58, i8* getelementptr inbounds ([16 x i8], [16 x i8]* @.str.4, i64 0, i64 0), i32 %5)
ret void
}