#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 debsig_ctx {
  int dummy;
};
typedef int /*<<< orphan*/ off_t;
typedef int /*<<< orphan*/ buf;

/* Variables and functions */
int /*<<< orphan*/ ds_printf(int, char *);
int /*<<< orphan*/ findMember(struct debsig_ctx const *, char *);
int /*<<< orphan*/ snprintf(char *, int, char *, char const *);
off_t checkSigExist(const struct debsig_ctx *ds_ctx, const char *name) {
  char buf[16];
  if (name == NULL) {
    ds_printf(-1, "checkSigExist: NULL values passed");
    return 0;
  }
  snprintf(buf, sizeof(buf) - 1, "_gpg%s", name);
  return findMember(ds_ctx, buf);
}


x86 assembly (clang, -O0):
<checkSigExist>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
mov    %rdi,-0x10(%rbp)
mov    %rsi,-0x18(%rbp)
cmpq   $0x0,-0x18(%rbp)
jne    1168 <checkSigExist+0x38>
mov    $0xffffffff,%edi
lea    0xea9(%rip),%rsi
call   1050 <ds_printf@plt>
movl   $0x0,-0x4(%rbp)
jmp    1191 <checkSigExist+0x61>
lea    -0x30(%rbp),%rdi
mov    -0x18(%rbp),%rcx
mov    $0xf,%esi
lea    0xea6(%rip),%rdx
call   1040 <snprintf@plt>
mov    -0x10(%rbp),%rdi
lea    -0x30(%rbp),%rsi
call   1030 <findMember@plt>
mov    %eax,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<checkSigExist>:
push   %r14
push   %rbx
sub    $0x18,%rsp
test   %rsi,%rsi
je     1166 <checkSigExist+0x36>
mov    %rsi,%rcx
mov    %rdi,%rbx
lea    0xed9(%rip),%rdx
mov    %rsp,%r14
mov    %r14,%rdi
mov    $0xf,%esi
call   1040 <snprintf@plt>
mov    %rbx,%rdi
mov    %r14,%rsi
call   1030 <findMember@plt>
jmp    1179 <checkSigExist+0x49>
lea    0xe93(%rip),%rsi
mov    $0xffffffff,%edi
call   1050 <ds_printf@plt>
xor    %eax,%eax
add    $0x18,%rsp
pop    %rbx
pop    %r14
ret

LLVM IR (-O0):
%struct.debsig_ctx = type { i32 }
@.str = [34 x i8] c"checkSigExist: NULL values passed\00"
@.str.1 = [7 x i8] c"_gpg%s\00"
define i32 @checkSigExist(%struct.debsig_ctx* %0, i8* %1) {
%3 = alloca i32
%4 = alloca %struct.debsig_ctx*
%5 = alloca i8*
%6 = alloca [16 x i8]
store %struct.debsig_ctx* %0, %struct.debsig_ctx** %4
store i8* %1, i8** %5
%7 = load i8*, i8** %5
%8 = icmp eq i8* %7, null
br i1 %8, label %9, label %11
9: ; preds = %2
%10 = call i32 @ds_printf(i32 -1, i8* getelementptr inbounds ([34 x i8], [34 x i8]* @.str, i64 0, i64 0))
store i32 0, i32* %3
br label %18
11: ; preds = %2
%12 = getelementptr inbounds [16 x i8], [16 x i8]* %6, i64 0, i64 0
%13 = load i8*, i8** %5
%14 = call i32 @snprintf(i8* %12, i32 15, i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str.1, i64 0, i64 0), i8* %13)
%15 = load %struct.debsig_ctx*, %struct.debsig_ctx** %4
%16 = getelementptr inbounds [16 x i8], [16 x i8]* %6, i64 0, i64 0
%17 = call i32 @findMember(%struct.debsig_ctx* %15, i8* %16)
store i32 %17, i32* %3
br label %18
18: ; preds = %11, %9
%19 = load i32, i32* %3
ret i32 %19
}

LLVM IR (-O2):
%struct.debsig_ctx = type { i32 }
@.str = [34 x i8] c"checkSigExist: NULL values passed\00"
@.str.1 = [7 x i8] c"_gpg%s\00"
define i32 @checkSigExist(%struct.debsig_ctx* %0, i8* %1) {
%3 = alloca [16 x i8]
%4 = getelementptr inbounds [16 x i8], [16 x i8]* %3, i64 0, i64 0
%5 = icmp eq i8* %1, null
br i1 %5, label %6, label %8
6: ; preds = %2
%7 = tail call i32 @ds_printf(i32 -1, i8* getelementptr inbounds ([34 x i8], [34 x i8]* @.str, i64 0, i64 0))
br label %11
8: ; preds = %2
%9 = call i32 @snprintf(i8* %4, i32 15, i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str.1, i64 0, i64 0), i8* %1)
%10 = call i32 @findMember(%struct.debsig_ctx* %0, i8* %4)
br label %11
11: ; preds = %8, %6
%12 = phi i32 [ 0, %6 ], [ %10, %8 ]
ret i32 %12
}