#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 */
char *CPhidget_strerror(int);
int CPhidget_getErrorDescription(int ErrorCode, const char **buf) {
  if (!buf)
    return 4;
  if ((ErrorCode < 0) || (ErrorCode >= 18)) {
    *buf = CPhidget_strerror(7);
    return 7;
  }
  *buf = CPhidget_strerror(ErrorCode);
  return 0;
}


x86 assembly (clang, -O0):
<CPhidget_getErrorDescription>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
mov    %edi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
cmpq   $0x0,-0x10(%rbp)
jne    1136 <CPhidget_getErrorDescription+0x26>
movl   $0x4,-0x4(%rbp)
jmp    1183 <CPhidget_getErrorDescription+0x73>
cmpl   $0x0,-0x8(%rbp)
jl     114a <CPhidget_getErrorDescription+0x3a>
cmpl   $0x12,-0x8(%rbp)
jl     116a <CPhidget_getErrorDescription+0x5a>
mov    $0x7,%edi
call   1030 <CPhidget_strerror@plt>
mov    %rax,%rcx
mov    -0x10(%rbp),%rax
mov    %rcx,(%rax)
movl   $0x7,-0x4(%rbp)
jmp    1183 <CPhidget_getErrorDescription+0x73>
mov    -0x8(%rbp),%edi
call   1030 <CPhidget_strerror@plt>
mov    %rax,%rcx
mov    -0x10(%rbp),%rax
mov    %rcx,(%rax)
movl   $0x0,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x10,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<CPhidget_getErrorDescription>:
push   %r14
push   %rbx
push   %rax
test   %rsi,%rsi
je     1136 <CPhidget_getErrorDescription+0x26>
mov    %rsi,%r14
xor    %ebx,%ebx
cmp    $0x12,%edi
mov    $0x7,%eax
cmovae %eax,%edi
cmovae %eax,%ebx
call   1030 <CPhidget_strerror@plt>
mov    %rax,(%r14)
jmp    113b <CPhidget_getErrorDescription+0x2b>
mov    $0x4,%ebx
mov    %ebx,%eax
add    $0x8,%rsp
pop    %rbx
pop    %r14
ret

LLVM IR (-O0):
define i32 @CPhidget_getErrorDescription(i32 %0, i8** %1) {
%3 = alloca i32
%4 = alloca i32
%5 = alloca i8**
store i32 %0, i32* %4
store i8** %1, i8*** %5
%6 = load i8**, i8*** %5
%7 = icmp ne i8** %6, null
br i1 %7, label %9, label %8
8: ; preds = %2
store i32 4, i32* %3
br label %22
9: ; preds = %2
%10 = load i32, i32* %4
%11 = icmp slt i32 %10, 0
br i1 %11, label %15, label %12
12: ; preds = %9
%13 = load i32, i32* %4
%14 = icmp sge i32 %13, 18
br i1 %14, label %15, label %18
15: ; preds = %12, %9
%16 = call i8* @CPhidget_strerror(i32 7)
%17 = load i8**, i8*** %5
store i8* %16, i8** %17
store i32 7, i32* %3
br label %22
18: ; preds = %12
%19 = load i32, i32* %4
%20 = call i8* @CPhidget_strerror(i32 %19)
%21 = load i8**, i8*** %5
store i8* %20, i8** %21
store i32 0, i32* %3
br label %22
22: ; preds = %18, %15, %8
%23 = load i32, i32* %3
ret i32 %23
}

LLVM IR (-O2):
define i32 @CPhidget_getErrorDescription(i32 %0, i8** writeonly %1) {
%3 = icmp eq i8** %1, null
br i1 %3, label %9, label %4
4: ; preds = %2
%5 = icmp ugt i32 %0, 17
%6 = select i1 %5, i32 7, i32 %0
%7 = select i1 %5, i32 7, i32 0
%8 = tail call i8* @CPhidget_strerror(i32 %6)
store i8* %8, i8** %1
br label %9
9: ; preds = %4, %2
%10 = phi i32 [ 4, %2 ], [ %7, %4 ]
ret i32 %10
}