#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 mg_request_info {
  int dummy;
};
struct mg_connection {
  int dummy;
};
typedef int /*<<< orphan*/ cb;

/* Variables and functions */
int /*<<< orphan*/ get_qsvar(struct mg_request_info const *, char *, char *,
                             int);
int /*<<< orphan*/ mg_printf(struct mg_connection *, char *, char *);
int handle_jsonp(struct mg_connection *conn,
                 const struct mg_request_info *request_info) {
  char cb[64];
  get_qsvar(request_info, "callback", cb, sizeof(cb));
  if (cb[0] != '\0') {
    mg_printf(conn, "%s(", cb);
  }
  return cb[0] == '\0' ? 0 : 1;
}


x86 assembly (clang, -O0):
<handle_jsonp>:
push   %rbp
mov    %rsp,%rbp
sub    $0x50,%rsp
mov    %rdi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
mov    -0x10(%rbp),%rdi
lea    -0x50(%rbp),%rdx
lea    0xec1(%rip),%rsi
mov    $0x40,%ecx
call   1030 <get_qsvar@plt>
movsbl -0x50(%rbp),%eax
cmp    $0x0,%eax
je     116a <handle_jsonp+0x4a>
mov    -0x8(%rbp),%rdi
lea    -0x50(%rbp),%rdx
lea    0xea4(%rip),%rsi
call   1040 <mg_printf@plt>
movsbl -0x50(%rbp),%edx
mov    $0x1,%eax
xor    %ecx,%ecx
cmp    $0x0,%edx
cmove  %ecx,%eax
add    $0x50,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<handle_jsonp>:
push   %rbx
sub    $0x40,%rsp
mov    %rsi,%rax
mov    %rdi,%rbx
lea    0xece(%rip),%rsi
mov    %rsp,%rdx
mov    %rax,%rdi
mov    $0x40,%ecx
call   1030 <get_qsvar@plt>
cmpb   $0x0,(%rsp)
je     1165 <handle_jsonp+0x45>
lea    0xeba(%rip),%rsi
mov    %rsp,%rdx
mov    %rbx,%rdi
call   1040 <mg_printf@plt>
xor    %eax,%eax
cmpb   $0x0,(%rsp)
setne  %al
jmp    1167 <handle_jsonp+0x47>
xor    %eax,%eax
add    $0x40,%rsp
pop    %rbx
ret

LLVM IR (-O0):
%struct.mg_connection = type { i32 }
%struct.mg_request_info = type { i32 }
@.str = [9 x i8] c"callback\00"
@.str.1 = [4 x i8] c"%s(\00"
define i32 @handle_jsonp(%struct.mg_connection* %0, %struct.mg_request_info* %1) {
%3 = alloca %struct.mg_connection*
%4 = alloca %struct.mg_request_info*
%5 = alloca [64 x i8]
store %struct.mg_connection* %0, %struct.mg_connection** %3
store %struct.mg_request_info* %1, %struct.mg_request_info** %4
%6 = load %struct.mg_request_info*, %struct.mg_request_info** %4
%7 = getelementptr inbounds [64 x i8], [64 x i8]* %5, i64 0, i64 0
%8 = call i32 @get_qsvar(%struct.mg_request_info* %6, i8* getelementptr inbounds ([9 x i8], [9 x i8]* @.str, i64 0, i64 0), i8* %7, i32 64)
%9 = getelementptr inbounds [64 x i8], [64 x i8]* %5, i64 0, i64 0
%10 = load i8, i8* %9
%11 = sext i8 %10 to i32
%12 = icmp ne i32 %11, 0
br i1 %12, label %13, label %17
13: ; preds = %2
%14 = load %struct.mg_connection*, %struct.mg_connection** %3
%15 = getelementptr inbounds [64 x i8], [64 x i8]* %5, i64 0, i64 0
%16 = call i32 @mg_printf(%struct.mg_connection* %14, i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.1, i64 0, i64 0), i8* %15)
br label %17
17: ; preds = %13, %2
%18 = getelementptr inbounds [64 x i8], [64 x i8]* %5, i64 0, i64 0
%19 = load i8, i8* %18
%20 = sext i8 %19 to i32
%21 = icmp eq i32 %20, 0
%22 = zext i1 %21 to i64
%23 = select i1 %21, i32 0, i32 1
ret i32 %23
}

LLVM IR (-O2):
%struct.mg_connection = type { i32 }
%struct.mg_request_info = type { i32 }
@.str = [9 x i8] c"callback\00"
@.str.1 = [4 x i8] c"%s(\00"
define i32 @handle_jsonp(%struct.mg_connection* %0, %struct.mg_request_info* %1) {
%3 = alloca [64 x i8]
%4 = getelementptr inbounds [64 x i8], [64 x i8]* %3, i64 0, i64 0
%5 = call i32 @get_qsvar(%struct.mg_request_info* %1, i8* getelementptr inbounds ([9 x i8], [9 x i8]* @.str, i64 0, i64 0), i8* %4, i32 64)
%6 = load i8, i8* %4
%7 = icmp eq i8 %6, 0
br i1 %7, label %13, label %8
8: ; preds = %2
%9 = call i32 @mg_printf(%struct.mg_connection* %0, i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.1, i64 0, i64 0), i8* %4)
%10 = load i8, i8* %4
%11 = icmp ne i8 %10, 0
%12 = zext i1 %11 to i32
br label %13
13: ; preds = %8, %2
%14 = phi i32 [ %12, %8 ], [ 0, %2 ]
ret i32 %14
}