#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 */
scalar_t__ CallBack2(int, void *, char *);
int /*<<< orphan*/ CheckRunningInMainThread(char *);
int GetIgorErrorMessage(int errCode, char errorMessage[256]) {
  int err;
  if (!CheckRunningInMainThread("GetIgorErrorMessage")) {
    *errorMessage = 0;
    return 978;
  }
  err = (int)CallBack2(180, (void *)errCode, errorMessage);
  if (err != 0)
    *errorMessage = 0;
  return err;
}


x86 assembly (clang, -O0):
<GetIgorErrorMessage>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %edi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
lea    0xeca(%rip),%rdi
call   1030 <CheckRunningInMainThread@plt>
cmp    $0x0,%eax
jne    1157 <GetIgorErrorMessage+0x37>
mov    -0x10(%rbp),%rax
movb   $0x0,(%rax)
movl   $0x3d2,-0x4(%rbp)
jmp    1183 <GetIgorErrorMessage+0x63>
movslq -0x8(%rbp),%rsi
mov    -0x10(%rbp),%rdx
mov    $0xb4,%edi
call   1040 <CallBack2@plt>
mov    %eax,-0x14(%rbp)
cmpl   $0x0,-0x14(%rbp)
je     117d <GetIgorErrorMessage+0x5d>
mov    -0x10(%rbp),%rax
movb   $0x0,(%rax)
mov    -0x14(%rbp),%eax
mov    %eax,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<GetIgorErrorMessage>:
push   %rbp
push   %rbx
push   %rax
mov    %rsi,%rbx
mov    %edi,%ebp
lea    0xed1(%rip),%rdi
call   1030 <CheckRunningInMainThread@plt>
test   %eax,%eax
je     1150 <GetIgorErrorMessage+0x30>
movslq %ebp,%rsi
mov    $0xb4,%edi
mov    %rbx,%rdx
call   1040 <CallBack2@plt>
test   %eax,%eax
jne    1155 <GetIgorErrorMessage+0x35>
xor    %eax,%eax
jmp    1158 <GetIgorErrorMessage+0x38>
mov    $0x3d2,%eax
movb   $0x0,(%rbx)
add    $0x8,%rsp
pop    %rbx
pop    %rbp
ret

LLVM IR (-O0):
@.str = [20 x i8] c"GetIgorErrorMessage\00"
define i32 @GetIgorErrorMessage(i32 %0, i8* %1) {
%3 = alloca i32
%4 = alloca i32
%5 = alloca i8*
%6 = alloca i32
store i32 %0, i32* %4
store i8* %1, i8** %5
%7 = call i32 @CheckRunningInMainThread(i8* getelementptr inbounds ([20 x i8], [20 x i8]* @.str, i64 0, i64 0))
%8 = icmp ne i32 %7, 0
br i1 %8, label %11, label %9
9: ; preds = %2
%10 = load i8*, i8** %5
store i8 0, i8* %10
store i32 978, i32* %3
br label %24
11: ; preds = %2
%12 = load i32, i32* %4
%13 = sext i32 %12 to i64
%14 = inttoptr i64 %13 to i8*
%15 = load i8*, i8** %5
%16 = call i64 @CallBack2(i32 180, i8* %14, i8* %15)
%17 = trunc i64 %16 to i32
store i32 %17, i32* %6
%18 = load i32, i32* %6
%19 = icmp ne i32 %18, 0
br i1 %19, label %20, label %22
20: ; preds = %11
%21 = load i8*, i8** %5
store i8 0, i8* %21
br label %22
22: ; preds = %20, %11
%23 = load i32, i32* %6
store i32 %23, i32* %3
br label %24
24: ; preds = %22, %9
%25 = load i32, i32* %3
ret i32 %25
}

LLVM IR (-O2):
@.str = [20 x i8] c"GetIgorErrorMessage\00"
define i32 @GetIgorErrorMessage(i32 %0, i8* %1) {
%3 = tail call i32 @CheckRunningInMainThread(i8* getelementptr inbounds ([20 x i8], [20 x i8]* @.str, i64 0, i64 0))
%4 = icmp eq i32 %3, 0
br i1 %4, label %11, label %5
5: ; preds = %2
%6 = sext i32 %0 to i64
%7 = inttoptr i64 %6 to i8*
%8 = tail call i64 @CallBack2(i32 180, i8* %7, i8* %1)
%9 = trunc i64 %8 to i32
%10 = icmp eq i32 %9, 0
br i1 %10, label %13, label %11
11: ; preds = %5, %2
%12 = phi i32 [ 978, %2 ], [ %9, %5 ]
store i8 0, i8* %1
br label %13
13: ; preds = %11, %5
%14 = phi i32 [ 0, %5 ], [ %12, %11 ]
ret i32 %14
}