#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 uint32_t;

/* Variables and functions */
char *malloc(int);
int /*<<< orphan*/ snprintf(char *, int, char *, char, int);
char *get_white_balance_single_adjust_str(uint32_t adjust, char negativeChar,
                                          char positiveChar) {
  char *ret = malloc(4);
  if (adjust < 7) {
    snprintf(ret, 4, "%c%d", negativeChar, 7 - adjust);
  } else if (adjust > 7) {
    snprintf(ret, 4, "%c%d", positiveChar, adjust - 7);
  } else {
    ret = "";
  }
  return ret;
}


x86 assembly (clang, -O0):
<get_white_balance_single_adjust_str>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
mov    %dl,%al
mov    %sil,%cl
mov    %edi,-0x4(%rbp)
mov    %cl,-0x5(%rbp)
mov    %al,-0x6(%rbp)
mov    $0x4,%edi
call   1040 <malloc@plt>
mov    %rax,-0x10(%rbp)
cmpl   $0x7,-0x4(%rbp)
jge    1178 <get_white_balance_single_adjust_str+0x58>
mov    -0x10(%rbp),%rdi
mov    -0x5(%rbp),%al
mov    $0x7,%r8d
sub    -0x4(%rbp),%r8d
mov    $0x4,%esi
lea    0xe95(%rip),%rdx
movsbl %al,%ecx
call   1030 <snprintf@plt>
jmp    11ba <get_white_balance_single_adjust_str+0x9a>
cmpl   $0x7,-0x4(%rbp)
jle    11aa <get_white_balance_single_adjust_str+0x8a>
mov    -0x10(%rbp),%rdi
mov    -0x6(%rbp),%al
mov    -0x4(%rbp),%r8d
sub    $0x7,%r8d
mov    $0x4,%esi
lea    0xe63(%rip),%rdx
movsbl %al,%ecx
call   1030 <snprintf@plt>
jmp    11b5 <get_white_balance_single_adjust_str+0x95>
lea    0xe53(%rip),%rax
mov    %rax,-0x10(%rbp)
jmp    11ba <get_white_balance_single_adjust_str+0x9a>
mov    -0x10(%rbp),%rax
add    $0x10,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<get_white_balance_single_adjust_str>:
push   %rbp
push   %r15
push   %r14
push   %rbx
push   %rax
mov    %edx,%r14d
mov    %esi,%r15d
mov    %edi,%ebp
mov    $0x4,%edi
call   1040 <malloc@plt>
mov    %rax,%rbx
cmp    $0x6,%ebp
jg     115f <get_white_balance_single_adjust_str+0x3f>
mov    $0x7,%r8d
sub    %ebp,%r8d
movsbl %r15b,%ecx
lea    0xeab(%rip),%rdx
mov    %rbx,%rdi
mov    $0x4,%esi
jmp    1186 <get_white_balance_single_adjust_str+0x66>
cmp    $0x7,%ebp
jne    116d <get_white_balance_single_adjust_str+0x4d>
lea    0xe99(%rip),%rbx
jmp    118b <get_white_balance_single_adjust_str+0x6b>
add    $0xfffffff9,%ebp
movsbl %r14b,%ecx
lea    0xe85(%rip),%rdx
mov    %rbx,%rdi
mov    $0x4,%esi
mov    %ebp,%r8d
call   1030 <snprintf@plt>
mov    %rbx,%rax
add    $0x8,%rsp
pop    %rbx
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
@.str = [5 x i8] c"%c%d\00"
@.str.1 = [1 x i8] zeroinitializer
define i8* @get_white_balance_single_adjust_str(i32 %0, i8 signext %1, i8 signext %2) {
%4 = alloca i32
%5 = alloca i8
%6 = alloca i8
%7 = alloca i8*
store i32 %0, i32* %4
store i8 %1, i8* %5
store i8 %2, i8* %6
%8 = call i8* @malloc(i32 4)
store i8* %8, i8** %7
%9 = load i32, i32* %4
%10 = icmp slt i32 %9, 7
br i1 %10, label %11, label %17
11: ; preds = %3
%12 = load i8*, i8** %7
%13 = load i8, i8* %5
%14 = load i32, i32* %4
%15 = sub nsw i32 7, %14
%16 = call i32 @snprintf(i8* %12, i32 4, i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str, i64 0, i64 0), i8 signext %13, i32 %15)
br label %28
17: ; preds = %3
%18 = load i32, i32* %4
%19 = icmp sgt i32 %18, 7
br i1 %19, label %20, label %26
20: ; preds = %17
%21 = load i8*, i8** %7
%22 = load i8, i8* %6
%23 = load i32, i32* %4
%24 = sub nsw i32 %23, 7
%25 = call i32 @snprintf(i8* %21, i32 4, i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str, i64 0, i64 0), i8 signext %22, i32 %24)
br label %27
26: ; preds = %17
store i8* getelementptr inbounds ([1 x i8], [1 x i8]* @.str.1, i64 0, i64 0), i8** %7
br label %27
27: ; preds = %26, %20
br label %28
28: ; preds = %27, %11
%29 = load i8*, i8** %7
ret i8* %29
}

LLVM IR (-O2):
@.str = [5 x i8] c"%c%d\00"
@.str.1 = [1 x i8] zeroinitializer
define i8* @get_white_balance_single_adjust_str(i32 %0, i8 signext %1, i8 signext %2) {
%4 = tail call dereferenceable_or_null(4) i8* @malloc(i32 4)
%5 = icmp slt i32 %0, 7
br i1 %5, label %6, label %9
6: ; preds = %3
%7 = sub nsw i32 7, %0
%8 = tail call i32 @snprintf(i8* %4, i32 4, i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str, i64 0, i64 0), i8 signext %1, i32 %7)
br label %14
9: ; preds = %3
%10 = icmp eq i32 %0, 7
br i1 %10, label %14, label %11
11: ; preds = %9
%12 = add nsw i32 %0, -7
%13 = tail call i32 @snprintf(i8* %4, i32 4, i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str, i64 0, i64 0), i8 signext %2, i32 %12)
br label %14
14: ; preds = %9, %11, %6
%15 = phi i8* [ %4, %6 ], [ %4, %11 ], [ getelementptr inbounds ([1 x i8], [1 x i8]* @.str.1, i64 0, i64 0), %9 ]
ret i8* %15
}