#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 */

/* Variables and functions */
int blnk_coff_idxstr(char *, char *);
int /*<<< orphan*/ sprintf(char *, char *, char *);
int blnk_coff_idxstr2(char *strs, char *str, int fl) {
  char buf[256];
  int i;
  if (!str)
    return (4);
  if (!*str)
    return (4);
  if (fl & 1) {
    i = blnk_coff_idxstr(strs, str);
    return (i);
  }
  sprintf(buf, "_%s", str);
  i = blnk_coff_idxstr(strs, buf);
  return (i);
}


x86 assembly (clang, -O0):
<blnk_coff_idxstr2>:
push   %rbp
mov    %rsp,%rbp
sub    $0x130,%rsp
mov    %rdi,-0x10(%rbp)
mov    %rsi,-0x18(%rbp)
mov    %edx,-0x1c(%rbp)
cmpq   $0x0,-0x18(%rbp)
jne    114d <blnk_coff_idxstr2+0x2d>
movl   $0x4,-0x4(%rbp)
jmp    11cc <blnk_coff_idxstr2+0xac>
mov    -0x18(%rbp),%rax
cmpb   $0x0,(%rax)
jne    1166 <blnk_coff_idxstr2+0x46>
movl   $0x4,-0x4(%rbp)
jmp    11cc <blnk_coff_idxstr2+0xac>
mov    -0x1c(%rbp),%eax
and    $0x1,%eax
cmp    $0x0,%eax
je     1196 <blnk_coff_idxstr2+0x76>
mov    -0x10(%rbp),%rdi
mov    -0x18(%rbp),%rsi
call   1030 <blnk_coff_idxstr@plt>
mov    %eax,-0x124(%rbp)
mov    -0x124(%rbp),%eax
mov    %eax,-0x4(%rbp)
jmp    11cc <blnk_coff_idxstr2+0xac>
lea    -0x120(%rbp),%rdi
mov    -0x18(%rbp),%rdx
lea    0xe58(%rip),%rsi
call   1040 <sprintf@plt>
mov    -0x10(%rbp),%rdi
lea    -0x120(%rbp),%rsi
call   1030 <blnk_coff_idxstr@plt>
mov    %eax,-0x124(%rbp)
mov    -0x124(%rbp),%eax
mov    %eax,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x130,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<blnk_coff_idxstr2>:
push   %r14
push   %rbx
sub    $0x108,%rsp
mov    $0x4,%eax
test   %rsi,%rsi
je     1164 <blnk_coff_idxstr2+0x44>
mov    %rsi,%rcx
cmpb   $0x0,(%rsi)
je     1164 <blnk_coff_idxstr2+0x44>
mov    %rdi,%rbx
test   $0x1,%dl
jne    116f <blnk_coff_idxstr2+0x4f>
lea    0xeb5(%rip),%rsi
mov    %rsp,%r14
mov    %r14,%rdi
mov    %rcx,%rdx
call   1040 <sprintf@plt>
mov    %rbx,%rdi
mov    %r14,%rsi
call   1030 <blnk_coff_idxstr@plt>
add    $0x108,%rsp
pop    %rbx
pop    %r14
ret
mov    %rbx,%rdi
mov    %rcx,%rsi
add    $0x108,%rsp
pop    %rbx
pop    %r14
jmp    1030 <blnk_coff_idxstr@plt>

LLVM IR (-O0):
@.str = [4 x i8] c"_%s\00"
define i32 @blnk_coff_idxstr2(i8* %0, i8* %1, i32 %2) {
%4 = alloca i32
%5 = alloca i8*
%6 = alloca i8*
%7 = alloca i32
%8 = alloca [256 x i8]
%9 = alloca i32
store i8* %0, i8** %5
store i8* %1, i8** %6
store i32 %2, i32* %7
%10 = load i8*, i8** %6
%11 = icmp ne i8* %10, null
br i1 %11, label %13, label %12
12: ; preds = %3
store i32 4, i32* %4
br label %35
13: ; preds = %3
%14 = load i8*, i8** %6
%15 = load i8, i8* %14
%16 = icmp ne i8 %15, 0
br i1 %16, label %18, label %17
17: ; preds = %13
store i32 4, i32* %4
br label %35
18: ; preds = %13
%19 = load i32, i32* %7
%20 = and i32 %19, 1
%21 = icmp ne i32 %20, 0
br i1 %21, label %22, label %27
22: ; preds = %18
%23 = load i8*, i8** %5
%24 = load i8*, i8** %6
%25 = call i32 @blnk_coff_idxstr(i8* %23, i8* %24)
store i32 %25, i32* %9
%26 = load i32, i32* %9
store i32 %26, i32* %4
br label %35
27: ; preds = %18
%28 = getelementptr inbounds [256 x i8], [256 x i8]* %8, i64 0, i64 0
%29 = load i8*, i8** %6
%30 = call i32 @sprintf(i8* %28, i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str, i64 0, i64 0), i8* %29)
%31 = load i8*, i8** %5
%32 = getelementptr inbounds [256 x i8], [256 x i8]* %8, i64 0, i64 0
%33 = call i32 @blnk_coff_idxstr(i8* %31, i8* %32)
store i32 %33, i32* %9
%34 = load i32, i32* %9
store i32 %34, i32* %4
br label %35
35: ; preds = %27, %22, %17, %12
%36 = load i32, i32* %4
ret i32 %36
}

LLVM IR (-O2):
@.str = [4 x i8] c"_%s\00"
define i32 @blnk_coff_idxstr2(i8* %0, i8* %1, i32 %2) {
%4 = alloca [256 x i8]
%5 = getelementptr inbounds [256 x i8], [256 x i8]* %4, i64 0, i64 0
%6 = icmp eq i8* %1, null
br i1 %6, label %18, label %7
7: ; preds = %3
%8 = load i8, i8* %1
%9 = icmp eq i8 %8, 0
br i1 %9, label %18, label %10
10: ; preds = %7
%11 = and i32 %2, 1
%12 = icmp eq i32 %11, 0
br i1 %12, label %15, label %13
13: ; preds = %10
%14 = tail call i32 @blnk_coff_idxstr(i8* %0, i8* %1)
br label %18
15: ; preds = %10
%16 = call i32 @sprintf(i8* %5, i8* dereferenceable(1) getelementptr inbounds ([4 x i8], [4 x i8]* @.str, i64 0, i64 0), i8* %1)
%17 = call i32 @blnk_coff_idxstr(i8* %0, i8* %5)
br label %18
18: ; preds = %7, %3, %15, %13
%19 = phi i32 [ %14, %13 ], [ %17, %15 ], [ 4, %3 ], [ 4, %7 ]
ret i32 %19
}