#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 */
struct ccache_credential {
  int dummy;
};

/* Variables and functions */
int pack_credential(struct ccache_credential *, char **, size_t *);
int ccache_pack_credential(struct ccache_credential *cred, char *out,
                           size_t *len) {
  size_t savelen = *len;
  int rc = pack_credential(cred, &out, len);
  if (rc < 0)
    return rc;
  *len = savelen - *len;
  return 0;
}


x86 assembly (clang, -O0):
<ccache_pack_credential>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
mov    %rdi,-0x10(%rbp)
mov    %rsi,-0x18(%rbp)
mov    %rdx,-0x20(%rbp)
mov    -0x20(%rbp),%rax
mov    (%rax),%rax
mov    %rax,-0x28(%rbp)
mov    -0x10(%rbp),%rdi
mov    -0x20(%rbp),%rdx
lea    -0x18(%rbp),%rsi
call   1030 <pack_credential@plt>
mov    %eax,-0x2c(%rbp)
cmpl   $0x0,-0x2c(%rbp)
jge    1158 <ccache_pack_credential+0x48>
mov    -0x2c(%rbp),%eax
mov    %eax,-0x4(%rbp)
jmp    1171 <ccache_pack_credential+0x61>
mov    -0x28(%rbp),%rcx
mov    -0x20(%rbp),%rax
sub    (%rax),%rcx
mov    -0x20(%rbp),%rax
mov    %rcx,(%rax)
movl   $0x0,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<ccache_pack_credential>:
push   %r14
push   %rbx
push   %rax
mov    %rdx,%rbx
mov    %rsi,(%rsp)
mov    (%rdx),%r14
mov    %rsp,%rsi
call   1030 <pack_credential@plt>
test   %eax,%eax
js     1132 <ccache_pack_credential+0x22>
sub    (%rbx),%r14
mov    %r14,(%rbx)
xor    %eax,%eax
add    $0x8,%rsp
pop    %rbx
pop    %r14
ret

LLVM IR (-O0):
%struct.ccache_credential = type { i32 }
define i32 @ccache_pack_credential(%struct.ccache_credential* %0, i8* %1, i64* %2) {
%4 = alloca i32
%5 = alloca %struct.ccache_credential*
%6 = alloca i8*
%7 = alloca i64*
%8 = alloca i64
%9 = alloca i32
store %struct.ccache_credential* %0, %struct.ccache_credential** %5
store i8* %1, i8** %6
store i64* %2, i64** %7
%10 = load i64*, i64** %7
%11 = load i64, i64* %10
store i64 %11, i64* %8
%12 = load %struct.ccache_credential*, %struct.ccache_credential** %5
%13 = load i64*, i64** %7
%14 = call i32 @pack_credential(%struct.ccache_credential* %12, i8** %6, i64* %13)
store i32 %14, i32* %9
%15 = load i32, i32* %9
%16 = icmp slt i32 %15, 0
br i1 %16, label %17, label %19
17: ; preds = %3
%18 = load i32, i32* %9
store i32 %18, i32* %4
br label %25
19: ; preds = %3
%20 = load i64, i64* %8
%21 = load i64*, i64** %7
%22 = load i64, i64* %21
%23 = sub i64 %20, %22
%24 = load i64*, i64** %7
store i64 %23, i64* %24
store i32 0, i32* %4
br label %25
25: ; preds = %19, %17
%26 = load i32, i32* %4
ret i32 %26
}

LLVM IR (-O2):
%struct.ccache_credential = type { i32 }
define i32 @ccache_pack_credential(%struct.ccache_credential* %0, i8* %1, i64* %2) {
%4 = alloca i8*
store i8* %1, i8** %4
%5 = load i64, i64* %2
%6 = call i32 @pack_credential(%struct.ccache_credential* %0, i8** %4, i64* %2)
%7 = icmp slt i32 %6, 0
br i1 %7, label %11, label %8
8: ; preds = %3
%9 = load i64, i64* %2
%10 = sub i64 %5, %9
store i64 %10, i64* %2
br label %11
11: ; preds = %3, %8
%12 = phi i32 [ 0, %8 ], [ %6, %3 ]
ret i32 %12
}