#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 read(int, char *, int);
int /*<<< orphan*/ usleep(int);
int write(int, unsigned int *, int);
int retrieveValue(int call, int *pointfile) {
  unsigned int cmd[16];
  int a, b, c, d, e;
  a = 105;
  b = 2350;
  c = 4587;
  d = 12587;
  e = 12;
  cmd[0] = call;
  cmd[1] = a >> 8;
  cmd[2] = a & 255;
  cmd[3] = b >> 8;
  cmd[4] = b & 255;
  cmd[5] = c >> 8;
  cmd[6] = c & 255;
  cmd[7] = d >> 8;
  cmd[8] = d & 255;
  cmd[9] = e >> 8;
  cmd[10] = e & 255;
  if (write(*pointfile, cmd, 11) == 11) {
    usleep(10000);
    char buf[3];
    if (read(*pointfile, buf, 2) == 2) {
      int resultant = buf[0] << 8 | buf[1];
      return resultant;
    } else {
      return -1;
    }
  }
}


x86 assembly (clang, -O0):
<retrieveValue>:
push   %rbp
mov    %rsp,%rbp
sub    $0x70,%rsp
mov    %edi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
movl   $0x69,-0x54(%rbp)
movl   $0x92e,-0x58(%rbp)
movl   $0x11eb,-0x5c(%rbp)
movl   $0x312b,-0x60(%rbp)
movl   $0xc,-0x64(%rbp)
mov    -0x8(%rbp),%eax
mov    %eax,-0x50(%rbp)
mov    -0x54(%rbp),%eax
sar    $0x8,%eax
mov    %eax,-0x4c(%rbp)
mov    -0x54(%rbp),%eax
and    $0xff,%eax
mov    %eax,-0x48(%rbp)
mov    -0x58(%rbp),%eax
sar    $0x8,%eax
mov    %eax,-0x44(%rbp)
mov    -0x58(%rbp),%eax
and    $0xff,%eax
mov    %eax,-0x40(%rbp)
mov    -0x5c(%rbp),%eax
sar    $0x8,%eax
mov    %eax,-0x3c(%rbp)
mov    -0x5c(%rbp),%eax
and    $0xff,%eax
mov    %eax,-0x38(%rbp)
mov    -0x60(%rbp),%eax
sar    $0x8,%eax
mov    %eax,-0x34(%rbp)
mov    -0x60(%rbp),%eax
and    $0xff,%eax
mov    %eax,-0x30(%rbp)
mov    -0x64(%rbp),%eax
sar    $0x8,%eax
mov    %eax,-0x2c(%rbp)
mov    -0x64(%rbp),%eax
and    $0xff,%eax
mov    %eax,-0x28(%rbp)
mov    -0x10(%rbp),%rax
mov    (%rax),%edi
lea    -0x50(%rbp),%rsi
mov    $0xb,%edx
call   1030 <write@plt>
cmp    $0xb,%eax
jne    1232 <retrieveValue+0x102>
mov    $0x2710,%edi
call   1050 <usleep@plt>
mov    -0x10(%rbp),%rax
mov    (%rax),%edi
lea    -0x67(%rbp),%rsi
mov    $0x2,%edx
call   1040 <read@plt>
cmp    $0x2,%eax
jne    122b <retrieveValue+0xfb>
movsbl -0x67(%rbp),%eax
shl    $0x8,%eax
movsbl -0x66(%rbp),%ecx
or     %ecx,%eax
mov    %eax,-0x6c(%rbp)
mov    -0x6c(%rbp),%eax
mov    %eax,-0x4(%rbp)
jmp    1232 <retrieveValue+0x102>
movl   $0xffffffff,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x70,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<retrieveValue>:
push   %rbx
sub    $0x50,%rsp
mov    %rsi,%rbx
mov    %edi,0x10(%rsp)
movaps 0xebd(%rip),%xmm0
movups %xmm0,0x14(%rsp)
movaps 0xec1(%rip),%xmm0
movups %xmm0,0x24(%rsp)
movabs $0xc00000000,%rax
mov    %rax,0x34(%rsp)
mov    (%rsi),%edi
lea    0x10(%rsp),%rsi
mov    $0xb,%edx
call   1030 <write@plt>
mov    %eax,%ecx
cmp    $0xb,%ecx
jne    11b0 <retrieveValue+0x80>
mov    $0x2710,%edi
call   1050 <usleep@plt>
mov    (%rbx),%edi
lea    0xd(%rsp),%rsi
mov    $0x2,%edx
call   1040 <read@plt>
movsbl 0xd(%rsp),%ecx
shl    $0x8,%ecx
movsbl 0xe(%rsp),%edx
or     %ecx,%edx
cmp    $0x2,%eax
mov    $0xffffffff,%eax
cmove  %edx,%eax
add    $0x50,%rsp
pop    %rbx
ret

LLVM IR (-O0):
define i32 @retrieveValue(i32 %0, i32* %1) {
%3 = alloca i32
%4 = alloca i32
%5 = alloca i32*
%6 = alloca [16 x i32]
%7 = alloca i32
%8 = alloca i32
%9 = alloca i32
%10 = alloca i32
%11 = alloca i32
%12 = alloca [3 x i8]
%13 = alloca i32
store i32 %0, i32* %4
store i32* %1, i32** %5
store i32 105, i32* %7
store i32 2350, i32* %8
store i32 4587, i32* %9
store i32 12587, i32* %10
store i32 12, i32* %11
%14 = load i32, i32* %4
%15 = getelementptr inbounds [16 x i32], [16 x i32]* %6, i64 0, i64 0
store i32 %14, i32* %15
%16 = load i32, i32* %7
%17 = ashr i32 %16, 8
%18 = getelementptr inbounds [16 x i32], [16 x i32]* %6, i64 0, i64 1
store i32 %17, i32* %18
%19 = load i32, i32* %7
%20 = and i32 %19, 255
%21 = getelementptr inbounds [16 x i32], [16 x i32]* %6, i64 0, i64 2
store i32 %20, i32* %21
%22 = load i32, i32* %8
%23 = ashr i32 %22, 8
%24 = getelementptr inbounds [16 x i32], [16 x i32]* %6, i64 0, i64 3
store i32 %23, i32* %24
%25 = load i32, i32* %8
%26 = and i32 %25, 255
%27 = getelementptr inbounds [16 x i32], [16 x i32]* %6, i64 0, i64 4
store i32 %26, i32* %27
%28 = load i32, i32* %9
%29 = ashr i32 %28, 8
%30 = getelementptr inbounds [16 x i32], [16 x i32]* %6, i64 0, i64 5
store i32 %29, i32* %30
%31 = load i32, i32* %9
%32 = and i32 %31, 255
%33 = getelementptr inbounds [16 x i32], [16 x i32]* %6, i64 0, i64 6
store i32 %32, i32* %33
%34 = load i32, i32* %10
%35 = ashr i32 %34, 8
%36 = getelementptr inbounds [16 x i32], [16 x i32]* %6, i64 0, i64 7
store i32 %35, i32* %36
%37 = load i32, i32* %10
%38 = and i32 %37, 255
%39 = getelementptr inbounds [16 x i32], [16 x i32]* %6, i64 0, i64 8
store i32 %38, i32* %39
%40 = load i32, i32* %11
%41 = ashr i32 %40, 8
%42 = getelementptr inbounds [16 x i32], [16 x i32]* %6, i64 0, i64 9
store i32 %41, i32* %42
%43 = load i32, i32* %11
%44 = and i32 %43, 255
%45 = getelementptr inbounds [16 x i32], [16 x i32]* %6, i64 0, i64 10
store i32 %44, i32* %45
%46 = load i32*, i32** %5
%47 = load i32, i32* %46
%48 = getelementptr inbounds [16 x i32], [16 x i32]* %6, i64 0, i64 0
%49 = call i32 @write(i32 %47, i32* %48, i32 11)
%50 = icmp eq i32 %49, 11
br i1 %50, label %51, label %69
51: ; preds = %2
%52 = call i32 @usleep(i32 10000)
%53 = load i32*, i32** %5
%54 = load i32, i32* %53
%55 = getelementptr inbounds [3 x i8], [3 x i8]* %12, i64 0, i64 0
%56 = call i32 @read(i32 %54, i8* %55, i32 2)
%57 = icmp eq i32 %56, 2
br i1 %57, label %58, label %68
58: ; preds = %51
%59 = getelementptr inbounds [3 x i8], [3 x i8]* %12, i64 0, i64 0
%60 = load i8, i8* %59
%61 = sext i8 %60 to i32
%62 = shl i32 %61, 8
%63 = getelementptr inbounds [3 x i8], [3 x i8]* %12, i64 0, i64 1
%64 = load i8, i8* %63
%65 = sext i8 %64 to i32
%66 = or i32 %62, %65
store i32 %66, i32* %13
%67 = load i32, i32* %13
store i32 %67, i32* %3
br label %69
68: ; preds = %51
store i32 -1, i32* %3
br label %69
69: ; preds = %58, %68, %2
%70 = load i32, i32* %3
ret i32 %70
}

LLVM IR (-O2):
define i32 @retrieveValue(i32 %0, i32* nocapture %1) {
%3 = alloca [16 x i32]
%4 = alloca [3 x i8]
%5 = bitcast [16 x i32]* %3 to i8*
%6 = getelementptr inbounds [16 x i32], [16 x i32]* %3, i64 0, i64 0
store i32 %0, i32* %6
%7 = getelementptr inbounds [16 x i32], [16 x i32]* %3, i64 0, i64 1
%8 = bitcast i32* %7 to <4 x i32>*
store <4 x i32> <i32 0, i32 105, i32 9, i32 46>, <4 x i32>* %8
%9 = getelementptr inbounds [16 x i32], [16 x i32]* %3, i64 0, i64 5
%10 = bitcast i32* %9 to <4 x i32>*
store <4 x i32> <i32 17, i32 235, i32 49, i32 43>, <4 x i32>* %10
%11 = getelementptr inbounds [16 x i32], [16 x i32]* %3, i64 0, i64 9
store i32 0, i32* %11
%12 = getelementptr inbounds [16 x i32], [16 x i32]* %3, i64 0, i64 10
store i32 12, i32* %12
%13 = load i32, i32* %1
%14 = call i32 @write(i32 %13, i32* %6, i32 11)
%15 = icmp eq i32 %14, 11
br i1 %15, label %16, label %30
16: ; preds = %2
%17 = tail call i32 @usleep(i32 10000)
%18 = getelementptr inbounds [3 x i8], [3 x i8]* %4, i64 0, i64 0
%19 = load i32, i32* %1
%20 = call i32 @read(i32 %19, i8* %18, i32 2)
%21 = icmp eq i32 %20, 2
%22 = load i8, i8* %18
%23 = sext i8 %22 to i32
%24 = shl nsw i32 %23, 8
%25 = getelementptr inbounds [3 x i8], [3 x i8]* %4, i64 0, i64 1
%26 = load i8, i8* %25
%27 = sext i8 %26 to i32
%28 = or i32 %24, %27
%29 = select i1 %21, i32 %28, i32 -1
br label %30
30: ; preds = %2, %16
%31 = phi i32 [ %29, %16 ], [ undef, %2 ]
ret i32 %31
}