#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*/ bzero(char *, int);
int /*<<< orphan*/ snprintf(char *, int, char *, char *, char *, char *, char *,
                            char *, char *, char *);
scalar_t__ spaghetti_get_prid(int /*<<< orphan*/ *, char *, int);
int spaghetti_post_file(char *, char *);
int /*<<< orphan*/ sprintf(char *, char *);
int spaghetti_post_wrapper(char *gamename, char *fullpath) {
  char final_url[1024];
  char pridbuf[128 + 1];
  char emuname[10];
  char platbuf[20];
  bzero(final_url, 1024);
  bzero(pridbuf, 128 + 1);
  sprintf(emuname, "advmame");
  sprintf(platbuf, "pandora");
  if (spaghetti_get_prid(NULL, pridbuf, 128) < 0) {
    return (-1);
  }
  snprintf(final_url, 1023, "%s/%s_%s/%s/%s/%s/%s", "http://127.0.0.1:13001",
           "tally", "1", gamename, platbuf, emuname, pridbuf);
  return (spaghetti_post_file(fullpath, final_url));
}


x86 assembly (clang, -O0):
<spaghetti_post_wrapper>:
push   %rbp
mov    %rsp,%rbp
push   %rbx
sub    $0x4e8,%rsp
mov    %rdi,-0x18(%rbp)
mov    %rsi,-0x20(%rbp)
lea    -0x420(%rbp),%rdi
mov    $0x400,%esi
call   1060 <bzero@plt>
lea    -0x4b0(%rbp),%rdi
mov    $0x81,%esi
call   1060 <bzero@plt>
lea    -0x4ba(%rbp),%rdi
lea    0xe6c(%rip),%rsi
call   1070 <sprintf@plt>
lea    -0x4d0(%rbp),%rdi
lea    0xe61(%rip),%rsi
call   1070 <sprintf@plt>
lea    -0x4b0(%rbp),%rsi
xor    %eax,%eax
mov    %eax,%edi
mov    $0x80,%edx
call   1040 <spaghetti_get_prid@plt>
cmp    $0x0,%rax
jge    11d7 <spaghetti_post_wrapper+0x87>
movl   $0xffffffff,-0xc(%rbp)
jmp    1243 <spaghetti_post_wrapper+0xf3>
lea    -0x420(%rbp),%rdi
mov    -0x18(%rbp),%rbx
lea    -0x4d0(%rbp),%r11
lea    -0x4ba(%rbp),%r10
lea    -0x4b0(%rbp),%rax
mov    $0x3ff,%esi
lea    0xe0d(%rip),%rdx
lea    0xe1b(%rip),%rcx
lea    0xe2b(%rip),%r8
lea    0xe22(%rip),%r9
mov    %rbx,(%rsp)
mov    %r11,0x8(%rsp)
mov    %r10,0x10(%rsp)
mov    %rax,0x18(%rsp)
call   1030 <snprintf@plt>
mov    -0x20(%rbp),%rdi
lea    -0x420(%rbp),%rsi
call   1050 <spaghetti_post_file@plt>
mov    %eax,-0xc(%rbp)
mov    -0xc(%rbp),%eax
add    $0x4e8,%rsp
pop    %rbx
pop    %rbp
ret

x86 assembly (clang, -O2):
<spaghetti_post_wrapper>:
push   %r15
push   %r14
push   %r12
push   %rbx
sub    $0x4c8,%rsp
mov    %rsi,%r14
mov    %rdi,%r15
lea    0xc0(%rsp),%rdi
mov    $0x400,%esi
call   1060 <bzero@plt>
lea    0x30(%rsp),%rbx
mov    %rbx,%rdi
mov    $0x81,%esi
call   1060 <bzero@plt>
movabs $0x656d616d766461,%rax
mov    %rax,(%rsp)
movabs $0x61726f646e6170,%rax
mov    %rax,0x10(%rsp)
xor    %edi,%edi
mov    %rbx,%rsi
mov    $0x80,%edx
call   1040 <spaghetti_get_prid@plt>
test   %rax,%rax
js     11f9 <spaghetti_post_wrapper+0xb9>
mov    %rsp,%rax
lea    0x10(%rsp),%r10
lea    0xe48(%rip),%rdx
lea    0xe56(%rip),%rcx
lea    0xe66(%rip),%r8
lea    0xe5d(%rip),%r9
lea    0xc0(%rsp),%r12
mov    %r12,%rdi
mov    $0x3ff,%esi
push   %rbx
push   %rax
push   %r10
push   %r15
call   1030 <snprintf@plt>
add    $0x20,%rsp
mov    %r14,%rdi
mov    %r12,%rsi
call   1050 <spaghetti_post_file@plt>
jmp    11fe <spaghetti_post_wrapper+0xbe>
mov    $0xffffffff,%eax
add    $0x4c8,%rsp
pop    %rbx
pop    %r12
pop    %r14
pop    %r15
ret

LLVM IR (-O0):
@.str = [8 x i8] c"advmame\00"
@.str.1 = [8 x i8] c"pandora\00"
@.str.2 = [21 x i8] c"%s/%s_%s/%s/%s/%s/%s\00"
@.str.3 = [23 x i8] c"http://127.0.0.1:13001\00"
@.str.4 = [6 x i8] c"tally\00"
@.str.5 = [2 x i8] c"1\00"
define i32 @spaghetti_post_wrapper(i8* %0, i8* %1) {
%3 = alloca i32
%4 = alloca i8*
%5 = alloca i8*
%6 = alloca [1024 x i8]
%7 = alloca [129 x i8]
%8 = alloca [10 x i8]
%9 = alloca [20 x i8]
store i8* %0, i8** %4
store i8* %1, i8** %5
%10 = getelementptr inbounds [1024 x i8], [1024 x i8]* %6, i64 0, i64 0
%11 = call i32 @bzero(i8* %10, i32 1024)
%12 = getelementptr inbounds [129 x i8], [129 x i8]* %7, i64 0, i64 0
%13 = call i32 @bzero(i8* %12, i32 129)
%14 = getelementptr inbounds [10 x i8], [10 x i8]* %8, i64 0, i64 0
%15 = call i32 @sprintf(i8* %14, i8* getelementptr inbounds ([8 x i8], [8 x i8]* @.str, i64 0, i64 0))
%16 = getelementptr inbounds [20 x i8], [20 x i8]* %9, i64 0, i64 0
%17 = call i32 @sprintf(i8* %16, i8* getelementptr inbounds ([8 x i8], [8 x i8]* @.str.1, i64 0, i64 0))
%18 = getelementptr inbounds [129 x i8], [129 x i8]* %7, i64 0, i64 0
%19 = call i64 @spaghetti_get_prid(i32* null, i8* %18, i32 128)
%20 = icmp slt i64 %19, 0
br i1 %20, label %21, label %22
21: ; preds = %2
store i32 -1, i32* %3
br label %32
22: ; preds = %2
%23 = getelementptr inbounds [1024 x i8], [1024 x i8]* %6, i64 0, i64 0
%24 = load i8*, i8** %4
%25 = getelementptr inbounds [20 x i8], [20 x i8]* %9, i64 0, i64 0
%26 = getelementptr inbounds [10 x i8], [10 x i8]* %8, i64 0, i64 0
%27 = getelementptr inbounds [129 x i8], [129 x i8]* %7, i64 0, i64 0
%28 = call i32 @snprintf(i8* %23, i32 1023, i8* getelementptr inbounds ([21 x i8], [21 x i8]* @.str.2, i64 0, i64 0), i8* getelementptr inbounds ([23 x i8], [23 x i8]* @.str.3, i64 0, i64 0), i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.4, i64 0, i64 0), i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.5, i64 0, i64 0), i8* %24, i8* %25, i8* %26, i8* %27)
%29 = load i8*, i8** %5
%30 = getelementptr inbounds [1024 x i8], [1024 x i8]* %6, i64 0, i64 0
%31 = call i32 @spaghetti_post_file(i8* %29, i8* %30)
store i32 %31, i32* %3
br label %32
32: ; preds = %22, %21
%33 = load i32, i32* %3
ret i32 %33
}

LLVM IR (-O2):
@.str.2 = [21 x i8] c"%s/%s_%s/%s/%s/%s/%s\00"
@.str.3 = [23 x i8] c"http://127.0.0.1:13001\00"
@.str.4 = [6 x i8] c"tally\00"
@.str.5 = [2 x i8] c"1\00"
define i32 @spaghetti_post_wrapper(i8* %0, i8* %1) {
%3 = alloca [1024 x i8]
%4 = alloca [129 x i8]
%5 = alloca [10 x i8]
%6 = alloca [20 x i8]
%7 = getelementptr inbounds [1024 x i8], [1024 x i8]* %3, i64 0, i64 0
%8 = getelementptr inbounds [129 x i8], [129 x i8]* %4, i64 0, i64 0
%9 = getelementptr inbounds [10 x i8], [10 x i8]* %5, i64 0, i64 0
%10 = getelementptr inbounds [20 x i8], [20 x i8]* %6, i64 0, i64 0
%11 = call i32 @bzero(i8* %7, i32 1024)
%12 = call i32 @bzero(i8* %8, i32 129)
%13 = bitcast [10 x i8]* %5 to i64*
store i64 28549237863507041, i64* %13
%14 = bitcast [20 x i8]* %6 to i64*
store i64 27428895492825456, i64* %14
%15 = call i64 @spaghetti_get_prid(i32* null, i8* %8, i32 128)
%16 = icmp slt i64 %15, 0
br i1 %16, label %20, label %17
17: ; preds = %2
%18 = call i32 @snprintf(i8* %7, i32 1023, i8* getelementptr inbounds ([21 x i8], [21 x i8]* @.str.2, i64 0, i64 0), i8* getelementptr inbounds ([23 x i8], [23 x i8]* @.str.3, i64 0, i64 0), i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.4, i64 0, i64 0), i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.5, i64 0, i64 0), i8* %0, i8* %10, i8* %9, i8* %8)
%19 = call i32 @spaghetti_post_file(i8* %1, i8* %7)
br label %20
20: ; preds = %2, %17
%21 = phi i32 [ %19, %17 ], [ -1, %2 ]
ret i32 %21
}