#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 module {
  int dummy;
};

/* Variables and functions */
char **module_getsym(struct module *, char const *);
int /*<<< orphan*/ printf(char *, char const *);
int /*<<< orphan*/ strcmp(char const *, char const *);
int testStr(struct module *mod, const char *name, const char *val) {
  const char **var = module_getsym(mod, name);
  if (!var) {
    printf("ERROR: Can't find %s\n", name);
  }
  return !strcmp(*var, val);
}


x86 assembly (clang, -O0):
<testStr>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %rdi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
mov    %rdx,-0x18(%rbp)
mov    -0x8(%rbp),%rdi
mov    -0x10(%rbp),%rsi
call   1030 <module_getsym@plt>
mov    %rax,-0x20(%rbp)
cmpq   $0x0,-0x20(%rbp)
jne    1170 <testStr+0x40>
mov    -0x10(%rbp),%rsi
lea    0xe95(%rip),%rdi
call   1040 <printf@plt>
mov    -0x20(%rbp),%rax
mov    (%rax),%rdi
mov    -0x18(%rbp),%rsi
call   1050 <strcmp@plt>
cmp    $0x0,%eax
setne  %al
xor    $0xff,%al
and    $0x1,%al
movzbl %al,%eax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<testStr>:
push   %r15
push   %r14
push   %rbx
mov    %rdx,%r14
mov    %rsi,%r15
call   1030 <module_getsym@plt>
mov    %rax,%rbx
test   %rax,%rax
jne    1157 <testStr+0x27>
lea    0xeb1(%rip),%rdi
mov    %r15,%rsi
call   1040 <printf@plt>
mov    (%rbx),%rdi
mov    %r14,%rsi
call   1050 <strcmp@plt>
xor    %ecx,%ecx
test   %eax,%eax
sete   %cl
mov    %ecx,%eax
pop    %rbx
pop    %r14
pop    %r15
ret

LLVM IR (-O0):
%struct.module = type { i32 }
@.str = [22 x i8] c"ERROR: Can't find %s\0A\00"
define i32 @testStr(%struct.module* %0, i8* %1, i8* %2) {
%4 = alloca %struct.module*
%5 = alloca i8*
%6 = alloca i8*
%7 = alloca i8**
store %struct.module* %0, %struct.module** %4
store i8* %1, i8** %5
store i8* %2, i8** %6
%8 = load %struct.module*, %struct.module** %4
%9 = load i8*, i8** %5
%10 = call i8** @module_getsym(%struct.module* %8, i8* %9)
store i8** %10, i8*** %7
%11 = load i8**, i8*** %7
%12 = icmp ne i8** %11, null
br i1 %12, label %16, label %13
13: ; preds = %3
%14 = load i8*, i8** %5
%15 = call i32 @printf(i8* getelementptr inbounds ([22 x i8], [22 x i8]* @.str, i64 0, i64 0), i8* %14)
br label %16
16: ; preds = %13, %3
%17 = load i8**, i8*** %7
%18 = load i8*, i8** %17
%19 = load i8*, i8** %6
%20 = call i32 @strcmp(i8* %18, i8* %19)
%21 = icmp ne i32 %20, 0
%22 = xor i1 %21, true
%23 = zext i1 %22 to i32
ret i32 %23
}

LLVM IR (-O2):
%struct.module = type { i32 }
@.str = [22 x i8] c"ERROR: Can't find %s\0A\00"
define i32 @testStr(%struct.module* %0, i8* %1, i8* nocapture %2) {
%4 = tail call i8** @module_getsym(%struct.module* %0, i8* %1)
%5 = icmp eq i8** %4, null
br i1 %5, label %6, label %8
6: ; preds = %3
%7 = tail call i32 @printf(i8* getelementptr inbounds ([22 x i8], [22 x i8]* @.str, i64 0, i64 0), i8* %1)
br label %8
8: ; preds = %6, %3
%9 = load i8*, i8** %4
%10 = tail call i32 @strcmp(i8* dereferenceable(1) %9, i8* dereferenceable(1) %2)
%11 = icmp eq i32 %10, 0
%12 = zext i1 %11 to i32
ret i32 %12
}