#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 */
typedef int /*<<< orphan*/ urle_user_name;
typedef int /*<<< orphan*/ urle_login_token;

/* Variables and functions */
scalar_t__ rc_url_encode(char *, int, char const *);
int snprintf(char *, size_t, char *, char *, char *, unsigned int, int,
             unsigned char, unsigned char, unsigned char, unsigned char,
             unsigned char, unsigned char, unsigned char, unsigned char,
             unsigned char, unsigned char, unsigned char, unsigned char,
             unsigned char, unsigned char, unsigned char, unsigned char);
int rc_url_submit_lboard(char *buffer, size_t size, const char *user_name,
                         const char *login_token, unsigned lboard_id, int value,
                         unsigned char hash[16]) {
  char urle_user_name[64];
  char urle_login_token[64];
  int written;
  if (rc_url_encode(urle_user_name, sizeof(urle_user_name), user_name) != 0) {
    return -1;
  }
  if (rc_url_encode(urle_login_token, sizeof(urle_login_token), login_token) !=
      0) {
    return -1;
  }
  written = snprintf(
      buffer, size,
      "http://retroachievements.org/"
      "dorequest.php?r=submitlbentry&u=%s&t=%s&i=%u&s=%d&v=%02x%02x%02x%02x%"
      "02x%02x%02x%02x%02x%02x%02x%02x%02x%02x%02x%02x",
      urle_user_name, urle_login_token, lboard_id, value, hash[0], hash[1],
      hash[2], hash[3], hash[4], hash[5], hash[6], hash[7], hash[8], hash[9],
      hash[10], hash[11], hash[12], hash[13], hash[14], hash[15]);
  return (size_t)written >= size ? -1 : 0;
}


x86 assembly (clang, -O0):
<rc_url_submit_lboard>:
push   %rbp
mov    %rsp,%rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
sub    $0x158,%rsp
mov    0x10(%rbp),%rax
mov    %rdi,-0x38(%rbp)
mov    %rsi,-0x40(%rbp)
mov    %rdx,-0x48(%rbp)
mov    %rcx,-0x50(%rbp)
mov    %r8d,-0x54(%rbp)
mov    %r9d,-0x58(%rbp)
lea    -0xa0(%rbp),%rdi
mov    -0x48(%rbp),%rdx
mov    $0x40,%esi
call   1030 <rc_url_encode@plt>
cmp    $0x0,%rax
je     117b <rc_url_submit_lboard+0x5b>
movl   $0xffffffff,-0x2c(%rbp)
jmp    1353 <rc_url_submit_lboard+0x233>
lea    -0xe0(%rbp),%rdi
mov    -0x50(%rbp),%rdx
mov    $0x40,%esi
call   1030 <rc_url_encode@plt>
cmp    $0x0,%rax
je     11a6 <rc_url_submit_lboard+0x86>
movl   $0xffffffff,-0x2c(%rbp)
jmp    1353 <rc_url_submit_lboard+0x233>
mov    -0x38(%rbp),%rdi
mov    -0x40(%rbp),%rsi
lea    -0xa0(%rbp),%rcx
lea    -0xe0(%rbp),%r8
mov    -0x54(%rbp),%r9d
mov    -0x58(%rbp),%eax
mov    0x10(%rbp),%rdx
mov    (%rdx),%dl
mov    %dl,-0xf8(%rbp)
mov    0x10(%rbp),%rdx
mov    0x1(%rdx),%dl
mov    %dl,-0xf7(%rbp)
mov    0x10(%rbp),%rdx
mov    0x2(%rdx),%dl
mov    %dl,-0xf6(%rbp)
mov    0x10(%rbp),%rdx
mov    0x3(%rdx),%dl
mov    %dl,-0xf5(%rbp)
mov    0x10(%rbp),%rdx
mov    0x4(%rdx),%dl
mov    %dl,-0xf4(%rbp)
mov    0x10(%rbp),%rdx
mov    0x5(%rdx),%dl
mov    %dl,-0xf3(%rbp)
mov    0x10(%rbp),%rdx
mov    0x6(%rdx),%dl
mov    %dl,-0xf2(%rbp)
mov    0x10(%rbp),%rdx
mov    0x7(%rdx),%dl
mov    %dl,-0xf1(%rbp)
mov    0x10(%rbp),%rdx
mov    0x8(%rdx),%r13b
mov    0x10(%rbp),%rdx
mov    0x9(%rdx),%r12b
mov    0x10(%rbp),%rdx
mov    0xa(%rdx),%r15b
mov    0x10(%rbp),%rdx
mov    0xb(%rdx),%r14b
mov    0x10(%rbp),%rdx
mov    0xc(%rdx),%bl
mov    0x10(%rbp),%rdx
mov    0xd(%rdx),%r11b
mov    0x10(%rbp),%rdx
mov    0xe(%rdx),%r10b
mov    0x10(%rbp),%rdx
mov    %rdx,-0xf0(%rbp)
lea    0xd8d(%rip),%rdx
mov    %eax,(%rsp)
mov    -0xf8(%rbp),%al
movzbl %al,%eax
mov    %eax,0x8(%rsp)
mov    -0xf7(%rbp),%al
movzbl %al,%eax
mov    %eax,0x10(%rsp)
mov    -0xf6(%rbp),%al
movzbl %al,%eax
mov    %eax,0x18(%rsp)
mov    -0xf5(%rbp),%al
movzbl %al,%eax
mov    %eax,0x20(%rsp)
mov    -0xf4(%rbp),%al
movzbl %al,%eax
mov    %eax,0x28(%rsp)
mov    -0xf3(%rbp),%al
movzbl %al,%eax
mov    %eax,0x30(%rsp)
mov    -0xf2(%rbp),%al
movzbl %al,%eax
mov    %eax,0x38(%rsp)
mov    -0xf1(%rbp),%al
movzbl %al,%eax
mov    %eax,0x40(%rsp)
mov    -0xf0(%rbp),%rax
movzbl %r13b,%r13d
mov    %r13d,0x48(%rsp)
movzbl %r12b,%r12d
mov    %r12d,0x50(%rsp)
movzbl %r15b,%r15d
mov    %r15d,0x58(%rsp)
movzbl %r14b,%r14d
mov    %r14d,0x60(%rsp)
movzbl %bl,%ebx
mov    %ebx,0x68(%rsp)
movzbl %r11b,%r11d
mov    %r11d,0x70(%rsp)
movzbl %r10b,%r10d
mov    %r10d,0x78(%rsp)
movzbl 0xf(%rax),%eax
mov    %eax,0x80(%rsp)
call   1040 <snprintf@plt>
mov    %eax,-0xe4(%rbp)
movslq -0xe4(%rbp),%rdx
mov    -0x40(%rbp),%rsi
xor    %eax,%eax
mov    $0xffffffff,%ecx
cmp    %rsi,%rdx
cmovae %ecx,%eax
mov    %eax,-0x2c(%rbp)
mov    -0x2c(%rbp),%eax
add    $0x158,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret

x86 assembly (clang, -O2):
<rc_url_submit_lboard>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
sub    $0xe8,%rsp
mov    %r9d,%r14d
mov    %r8d,%r12d
mov    %rcx,%rbx
mov    %rsi,%r15
mov    %rdi,%r13
lea    0xa0(%rsp),%rdi
mov    $0x40,%esi
call   1030 <rc_url_encode@plt>
mov    $0xffffffff,%ebp
test   %rax,%rax
jne    1279 <rc_url_submit_lboard+0x159>
lea    0x60(%rsp),%rdi
mov    $0x40,%esi
mov    %rbx,%rdx
call   1030 <rc_url_encode@plt>
test   %rax,%rax
jne    1279 <rc_url_submit_lboard+0x159>
mov    0x120(%rsp),%rcx
movzbl (%rcx),%eax
mov    %rax,0x58(%rsp)
movzbl 0x1(%rcx),%eax
mov    %rax,0x50(%rsp)
movzbl 0x2(%rcx),%eax
mov    %rax,0x48(%rsp)
movzbl 0x3(%rcx),%eax
mov    %rax,0x40(%rsp)
movzbl 0x4(%rcx),%eax
mov    %rax,0x38(%rsp)
movzbl 0x5(%rcx),%eax
mov    %rax,0x30(%rsp)
movzbl 0x6(%rcx),%eax
mov    %rax,0x28(%rsp)
movzbl 0x7(%rcx),%eax
mov    %rax,0x20(%rsp)
movzbl 0x8(%rcx),%eax
mov    %rax,0x18(%rsp)
movzbl 0x9(%rcx),%eax
mov    %rax,0x10(%rsp)
movzbl 0xa(%rcx),%eax
mov    %rax,0x8(%rsp)
movzbl 0xb(%rcx),%r11d
movzbl 0xc(%rcx),%ebx
movzbl 0xd(%rcx),%eax
movzbl 0xe(%rcx),%ebp
movzbl 0xf(%rcx),%r10d
sub    $0x8,%rsp
lea    0xdfa(%rip),%rdx
lea    0xa8(%rsp),%rcx
lea    0x68(%rsp),%r8
mov    %r13,%rdi
mov    %r15,%rsi
mov    %r12d,%r9d
push   %r10
push   %rbp
push   %rax
push   %rbx
push   %r11
push   0x38(%rsp)
push   0x48(%rsp)
push   0x58(%rsp)
push   0x68(%rsp)
push   0x78(%rsp)
push   0x88(%rsp)
push   0x98(%rsp)
push   0xa8(%rsp)
push   0xb8(%rsp)
push   0xc8(%rsp)
push   0xd8(%rsp)
push   %r14
call   1040 <snprintf@plt>
add    $0x90,%rsp
cltq
xor    %ebp,%ebp
cmp    %r15,%rax
adc    $0xffffffff,%ebp
mov    %ebp,%eax
add    $0xe8,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
@.str = [146 x i8] c"http://retroachievements.org/dorequest.php?r=submitlbentry&u=%s&t=%s&i=%u&s=%d&v=%02x%02x%02x%02x%02x%02x%02x%02x%02x%02x%02x%02x%02x%02x%02x%02x\00"
define i32 @rc_url_submit_lboard(i8* %0, i64 %1, i8* %2, i8* %3, i32 %4, i32 %5, i8* %6) {
%8 = alloca i32
%9 = alloca i8*
%10 = alloca i64
%11 = alloca i8*
%12 = alloca i8*
%13 = alloca i32
%14 = alloca i32
%15 = alloca i8*
%16 = alloca [64 x i8]
%17 = alloca [64 x i8]
%18 = alloca i32
store i8* %0, i8** %9
store i64 %1, i64* %10
store i8* %2, i8** %11
store i8* %3, i8** %12
store i32 %4, i32* %13
store i32 %5, i32* %14
store i8* %6, i8** %15
%19 = getelementptr inbounds [64 x i8], [64 x i8]* %16, i64 0, i64 0
%20 = load i8*, i8** %11
%21 = call i64 @rc_url_encode(i8* %19, i32 64, i8* %20)
%22 = icmp ne i64 %21, 0
br i1 %22, label %23, label %24
23: ; preds = %7
store i32 -1, i32* %8
br label %92
24: ; preds = %7
%25 = getelementptr inbounds [64 x i8], [64 x i8]* %17, i64 0, i64 0
%26 = load i8*, i8** %12
%27 = call i64 @rc_url_encode(i8* %25, i32 64, i8* %26)
%28 = icmp ne i64 %27, 0
br i1 %28, label %29, label %30
29: ; preds = %24
store i32 -1, i32* %8
br label %92
30: ; preds = %24
%31 = load i8*, i8** %9
%32 = load i64, i64* %10
%33 = getelementptr inbounds [64 x i8], [64 x i8]* %16, i64 0, i64 0
%34 = getelementptr inbounds [64 x i8], [64 x i8]* %17, i64 0, i64 0
%35 = load i32, i32* %13
%36 = load i32, i32* %14
%37 = load i8*, i8** %15
%38 = getelementptr inbounds i8, i8* %37, i64 0
%39 = load i8, i8* %38
%40 = load i8*, i8** %15
%41 = getelementptr inbounds i8, i8* %40, i64 1
%42 = load i8, i8* %41
%43 = load i8*, i8** %15
%44 = getelementptr inbounds i8, i8* %43, i64 2
%45 = load i8, i8* %44
%46 = load i8*, i8** %15
%47 = getelementptr inbounds i8, i8* %46, i64 3
%48 = load i8, i8* %47
%49 = load i8*, i8** %15
%50 = getelementptr inbounds i8, i8* %49, i64 4
%51 = load i8, i8* %50
%52 = load i8*, i8** %15
%53 = getelementptr inbounds i8, i8* %52, i64 5
%54 = load i8, i8* %53
%55 = load i8*, i8** %15
%56 = getelementptr inbounds i8, i8* %55, i64 6
%57 = load i8, i8* %56
%58 = load i8*, i8** %15
%59 = getelementptr inbounds i8, i8* %58, i64 7
%60 = load i8, i8* %59
%61 = load i8*, i8** %15
%62 = getelementptr inbounds i8, i8* %61, i64 8
%63 = load i8, i8* %62
%64 = load i8*, i8** %15
%65 = getelementptr inbounds i8, i8* %64, i64 9
%66 = load i8, i8* %65
%67 = load i8*, i8** %15
%68 = getelementptr inbounds i8, i8* %67, i64 10
%69 = load i8, i8* %68
%70 = load i8*, i8** %15
%71 = getelementptr inbounds i8, i8* %70, i64 11
%72 = load i8, i8* %71
%73 = load i8*, i8** %15
%74 = getelementptr inbounds i8, i8* %73, i64 12
%75 = load i8, i8* %74
%76 = load i8*, i8** %15
%77 = getelementptr inbounds i8, i8* %76, i64 13
%78 = load i8, i8* %77
%79 = load i8*, i8** %15
%80 = getelementptr inbounds i8, i8* %79, i64 14
%81 = load i8, i8* %80
%82 = load i8*, i8** %15
%83 = getelementptr inbounds i8, i8* %82, i64 15
%84 = load i8, i8* %83
%85 = call i32 @snprintf(i8* %31, i64 %32, i8* getelementptr inbounds ([146 x i8], [146 x i8]* @.str, i64 0, i64 0), i8* %33, i8* %34, i32 %35, i32 %36, i8 zeroext %39, i8 zeroext %42, i8 zeroext %45, i8 zeroext %48, i8 zeroext %51, i8 zeroext %54, i8 zeroext %57, i8 zeroext %60, i8 zeroext %63, i8 zeroext %66, i8 zeroext %69, i8 zeroext %72, i8 zeroext %75, i8 zeroext %78, i8 zeroext %81, i8 zeroext %84)
store i32 %85, i32* %18
%86 = load i32, i32* %18
%87 = sext i32 %86 to i64
%88 = load i64, i64* %10
%89 = icmp uge i64 %87, %88
%90 = zext i1 %89 to i64
%91 = select i1 %89, i32 -1, i32 0
store i32 %91, i32* %8
br label %92
92: ; preds = %30, %29, %23
%93 = load i32, i32* %8
ret i32 %93
}

LLVM IR (-O2):
@.str = [146 x i8] c"http://retroachievements.org/dorequest.php?r=submitlbentry&u=%s&t=%s&i=%u&s=%d&v=%02x%02x%02x%02x%02x%02x%02x%02x%02x%02x%02x%02x%02x%02x%02x%02x\00"
define i32 @rc_url_submit_lboard(i8* %0, i64 %1, i8* %2, i8* %3, i32 %4, i32 %5, i8* nocapture %6) {
%8 = alloca [64 x i8]
%9 = alloca [64 x i8]
%10 = getelementptr inbounds [64 x i8], [64 x i8]* %8, i64 0, i64 0
%11 = getelementptr inbounds [64 x i8], [64 x i8]* %9, i64 0, i64 0
%12 = call i64 @rc_url_encode(i8* %10, i32 64, i8* %2)
%13 = icmp eq i64 %12, 0
br i1 %13, label %14, label %53
14: ; preds = %7
%15 = call i64 @rc_url_encode(i8* %11, i32 64, i8* %3)
%16 = icmp eq i64 %15, 0
br i1 %16, label %17, label %53
17: ; preds = %14
%18 = load i8, i8* %6
%19 = getelementptr inbounds i8, i8* %6, i64 1
%20 = load i8, i8* %19
%21 = getelementptr inbounds i8, i8* %6, i64 2
%22 = load i8, i8* %21
%23 = getelementptr inbounds i8, i8* %6, i64 3
%24 = load i8, i8* %23
%25 = getelementptr inbounds i8, i8* %6, i64 4
%26 = load i8, i8* %25
%27 = getelementptr inbounds i8, i8* %6, i64 5
%28 = load i8, i8* %27
%29 = getelementptr inbounds i8, i8* %6, i64 6
%30 = load i8, i8* %29
%31 = getelementptr inbounds i8, i8* %6, i64 7
%32 = load i8, i8* %31
%33 = getelementptr inbounds i8, i8* %6, i64 8
%34 = load i8, i8* %33
%35 = getelementptr inbounds i8, i8* %6, i64 9
%36 = load i8, i8* %35
%37 = getelementptr inbounds i8, i8* %6, i64 10
%38 = load i8, i8* %37
%39 = getelementptr inbounds i8, i8* %6, i64 11
%40 = load i8, i8* %39
%41 = getelementptr inbounds i8, i8* %6, i64 12
%42 = load i8, i8* %41
%43 = getelementptr inbounds i8, i8* %6, i64 13
%44 = load i8, i8* %43
%45 = getelementptr inbounds i8, i8* %6, i64 14
%46 = load i8, i8* %45
%47 = getelementptr inbounds i8, i8* %6, i64 15
%48 = load i8, i8* %47
%49 = call i32 @snprintf(i8* %0, i64 %1, i8* getelementptr inbounds ([146 x i8], [146 x i8]* @.str, i64 0, i64 0), i8* %10, i8* %11, i32 %4, i32 %5, i8 zeroext %18, i8 zeroext %20, i8 zeroext %22, i8 zeroext %24, i8 zeroext %26, i8 zeroext %28, i8 zeroext %30, i8 zeroext %32, i8 zeroext %34, i8 zeroext %36, i8 zeroext %38, i8 zeroext %40, i8 zeroext %42, i8 zeroext %44, i8 zeroext %46, i8 zeroext %48)
%50 = sext i32 %49 to i64
%51 = icmp uge i64 %50, %1
%52 = sext i1 %51 to i32
br label %53
53: ; preds = %14, %7, %17
%54 = phi i32 [ %52, %17 ], [ -1, %7 ], [ -1, %14 ]
ret i32 %54
}