#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 /*<<< orphan*/ printf(char *, ...);
int /*<<< orphan*/ sclose(int);
int sopen(int);
int sopen_adc(int /*<<< orphan*/, float);
scalar_t__ sread(int, int *);
int main() {
  int data[3];
  int sfd = -1;
  printf("Accelerometer:\n");
  sfd = sopen(3);
  if (sread(sfd, data) == 0) {
    printf("\tRead successful. Data received: %i, %i and %i\n\n", data[0],
           data[1], data[2]);
  } else {
    printf("\tRead failed\n\n");
  }
  sclose(sfd);
  data[0] = 0;
  data[1] = 0;
  data[2] = 0;
  printf("ADC:\n");
  sfd = sopen_adc(0, 1.0f);
  if (sread(sfd, data) == 0) {
    printf("\tRead successful. Data received: %i\n\n", data[0]);
  } else {
    printf("\tRead failed\n\n");
  }
  sclose(sfd);
  data[0] = 0;
  printf("Ambient light:\n");
  sfd = sopen(4);
  if (sread(sfd, data) == 0) {
    printf("\tRead successful. Data received: %i\n\n", data[0]);
  } else {
    printf("\tRead failed\n\n");
  }
  sclose(sfd);
  data[0] = 0;
  printf("Temperature:\n");
  sfd = sopen(1);
  if (sread(sfd, data) == 0) {
    printf("\tRead successful. Data received: %i\n\n", data[0]);
  } else {
    printf("\tRead failed\n\n");
  }
  sclose(sfd);
  data[0] = 0;
  printf("Humidity:\n");
  sfd = sopen(2);
  if (sread(sfd, data) == 0) {
    printf("\tRead successful. Data received: %i\n\n", data[0]);
  } else {
    printf("\tRead failed\n\n");
  }
  sclose(sfd);
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
movl   $0x0,-0x4(%rbp)
movl   $0xffffffff,-0x14(%rbp)
lea    0xe97(%rip),%rdi
mov    $0x0,%al
call   1050 <printf@plt>
mov    $0x3,%edi
call   1040 <sopen@plt>
mov    %eax,-0x14(%rbp)
mov    -0x14(%rbp),%edi
lea    -0x10(%rbp),%rsi
call   1060 <sread@plt>
cmp    $0x0,%rax
jne    11b3 <main+0x63>
mov    -0x10(%rbp),%esi
mov    -0xc(%rbp),%edx
mov    -0x8(%rbp),%ecx
lea    0xe6d(%rip),%rdi
mov    $0x0,%al
call   1050 <printf@plt>
jmp    11c1 <main+0x71>
lea    0xe8b(%rip),%rdi
mov    $0x0,%al
call   1050 <printf@plt>
mov    -0x14(%rbp),%edi
call   1030 <sclose@plt>
movl   $0x0,-0x10(%rbp)
movl   $0x0,-0xc(%rbp)
movl   $0x0,-0x8(%rbp)
lea    0xe6f(%rip),%rdi
mov    $0x0,%al
call   1050 <printf@plt>
xor    %edi,%edi
movss  0xe0a(%rip),%xmm0
call   1070 <sopen_adc@plt>
mov    %eax,-0x14(%rbp)
mov    -0x14(%rbp),%edi
lea    -0x10(%rbp),%rsi
call   1060 <sread@plt>
cmp    $0x0,%rax
jne    122a <main+0xda>
mov    -0x10(%rbp),%esi
lea    0xe3c(%rip),%rdi
mov    $0x0,%al
call   1050 <printf@plt>
jmp    1238 <main+0xe8>
lea    0xe14(%rip),%rdi
mov    $0x0,%al
call   1050 <printf@plt>
mov    -0x14(%rbp),%edi
call   1030 <sclose@plt>
movl   $0x0,-0x10(%rbp)
lea    0xe32(%rip),%rdi
mov    $0x0,%al
call   1050 <printf@plt>
mov    $0x4,%edi
call   1040 <sopen@plt>
mov    %eax,-0x14(%rbp)
mov    -0x14(%rbp),%edi
lea    -0x10(%rbp),%rsi
call   1060 <sread@plt>
cmp    $0x0,%rax
jne    128e <main+0x13e>
mov    -0x10(%rbp),%esi
lea    0xdd8(%rip),%rdi
mov    $0x0,%al
call   1050 <printf@plt>
jmp    129c <main+0x14c>
lea    0xdb0(%rip),%rdi
mov    $0x0,%al
call   1050 <printf@plt>
mov    -0x14(%rbp),%edi
call   1030 <sclose@plt>
movl   $0x0,-0x10(%rbp)
lea    0xdde(%rip),%rdi
mov    $0x0,%al
call   1050 <printf@plt>
mov    $0x1,%edi
call   1040 <sopen@plt>
mov    %eax,-0x14(%rbp)
mov    -0x14(%rbp),%edi
lea    -0x10(%rbp),%rsi
call   1060 <sread@plt>
cmp    $0x0,%rax
jne    12f2 <main+0x1a2>
mov    -0x10(%rbp),%esi
lea    0xd74(%rip),%rdi
mov    $0x0,%al
call   1050 <printf@plt>
jmp    1300 <main+0x1b0>
lea    0xd4c(%rip),%rdi
mov    $0x0,%al
call   1050 <printf@plt>
mov    -0x14(%rbp),%edi
call   1030 <sclose@plt>
movl   $0x0,-0x10(%rbp)
lea    0xd88(%rip),%rdi
mov    $0x0,%al
call   1050 <printf@plt>
mov    $0x2,%edi
call   1040 <sopen@plt>
mov    %eax,-0x14(%rbp)
mov    -0x14(%rbp),%edi
lea    -0x10(%rbp),%rsi
call   1060 <sread@plt>
cmp    $0x0,%rax
jne    1356 <main+0x206>
mov    -0x10(%rbp),%esi
lea    0xd10(%rip),%rdi
mov    $0x0,%al
call   1050 <printf@plt>
jmp    1364 <main+0x214>
lea    0xce8(%rip),%rdi
mov    $0x0,%al
call   1050 <printf@plt>
mov    -0x14(%rbp),%edi
call   1030 <sclose@plt>
mov    -0x4(%rbp),%eax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbx
sub    $0x10,%rsp
lea    0xeef(%rip),%rdi
call   1040 <puts@plt>
mov    $0x3,%edi
call   1050 <sopen@plt>
mov    %eax,%ebx
lea    0x4(%rsp),%rsi
mov    %eax,%edi
call   1070 <sread@plt>
test   %rax,%rax
je     119c <main+0x3c>
lea    0xf00(%rip),%rdi
call   1040 <puts@plt>
jmp    11b6 <main+0x56>
mov    0x4(%rsp),%esi
mov    0x8(%rsp),%edx
mov    0xc(%rsp),%ecx
lea    0xe55(%rip),%rdi
xor    %eax,%eax
call   1060 <printf@plt>
mov    %ebx,%edi
call   1030 <sclose@plt>
movq   $0x0,0x4(%rsp)
movl   $0x0,0xc(%rsp)
lea    0xe95(%rip),%rdi
call   1040 <puts@plt>
movss  0xe1e(%rip),%xmm0
xor    %edi,%edi
call   1080 <sopen_adc@plt>
mov    %eax,%ebx
lea    0x4(%rsp),%rsi
mov    %eax,%edi
call   1070 <sread@plt>
test   %rax,%rax
je     120a <main+0xaa>
lea    0xe92(%rip),%rdi
call   1040 <puts@plt>
jmp    121c <main+0xbc>
mov    0x4(%rsp),%esi
lea    0xe20(%rip),%rdi
xor    %eax,%eax
call   1060 <printf@plt>
mov    %ebx,%edi
call   1030 <sclose@plt>
movl   $0x0,0x4(%rsp)
lea    0xe3d(%rip),%rdi
call   1040 <puts@plt>
mov    $0x4,%edi
call   1050 <sopen@plt>
mov    %eax,%ebx
lea    0x4(%rsp),%rsi
mov    %eax,%edi
call   1070 <sread@plt>
test   %rax,%rax
je     1262 <main+0x102>
lea    0xe3a(%rip),%rdi
call   1040 <puts@plt>
jmp    1274 <main+0x114>
mov    0x4(%rsp),%esi
lea    0xdc8(%rip),%rdi
xor    %eax,%eax
call   1060 <printf@plt>
mov    %ebx,%edi
call   1030 <sclose@plt>
movl   $0x0,0x4(%rsp)
lea    0xdf4(%rip),%rdi
call   1040 <puts@plt>
mov    $0x1,%edi
call   1050 <sopen@plt>
mov    %eax,%ebx
lea    0x4(%rsp),%rsi
mov    %eax,%edi
call   1070 <sread@plt>
test   %rax,%rax
je     12ba <main+0x15a>
lea    0xde2(%rip),%rdi
call   1040 <puts@plt>
jmp    12cc <main+0x16c>
mov    0x4(%rsp),%esi
lea    0xd70(%rip),%rdi
xor    %eax,%eax
call   1060 <printf@plt>
mov    %ebx,%edi
call   1030 <sclose@plt>
movl   $0x0,0x4(%rsp)
lea    0xda9(%rip),%rdi
call   1040 <puts@plt>
mov    $0x2,%edi
call   1050 <sopen@plt>
mov    %eax,%ebx
lea    0x4(%rsp),%rsi
mov    %eax,%edi
call   1070 <sread@plt>
test   %rax,%rax
je     1312 <main+0x1b2>
lea    0xd8a(%rip),%rdi
call   1040 <puts@plt>
jmp    1324 <main+0x1c4>
mov    0x4(%rsp),%esi
lea    0xd18(%rip),%rdi
xor    %eax,%eax
call   1060 <printf@plt>
mov    %ebx,%edi
call   1030 <sclose@plt>
xor    %eax,%eax
add    $0x10,%rsp
pop    %rbx
ret

LLVM IR (-O0):
@.str = [16 x i8] c"Accelerometer:\0A\00"
@.str.1 = [49 x i8] c"\09Read successful. Data received: %i, %i and %i\0A\0A\00"
@.str.2 = [15 x i8] c"\09Read failed\0A\0A\00"
@.str.3 = [6 x i8] c"ADC:\0A\00"
@.str.4 = [38 x i8] c"\09Read successful. Data received: %i\0A\0A\00"
@.str.5 = [16 x i8] c"Ambient light:\0A\00"
@.str.6 = [14 x i8] c"Temperature:\0A\00"
@.str.7 = [11 x i8] c"Humidity:\0A\00"
define i32 @main() {
%1 = alloca i32
%2 = alloca [3 x i32]
%3 = alloca i32
store i32 0, i32* %1
store i32 -1, i32* %3
%4 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([16 x i8], [16 x i8]* @.str, i64 0, i64 0))
%5 = call i32 @sopen(i32 3)
store i32 %5, i32* %3
%6 = load i32, i32* %3
%7 = getelementptr inbounds [3 x i32], [3 x i32]* %2, i64 0, i64 0
%8 = call i64 @sread(i32 %6, i32* %7)
%9 = icmp eq i64 %8, 0
br i1 %9, label %10, label %18
10: ; preds = %0
%11 = getelementptr inbounds [3 x i32], [3 x i32]* %2, i64 0, i64 0
%12 = load i32, i32* %11
%13 = getelementptr inbounds [3 x i32], [3 x i32]* %2, i64 0, i64 1
%14 = load i32, i32* %13
%15 = getelementptr inbounds [3 x i32], [3 x i32]* %2, i64 0, i64 2
%16 = load i32, i32* %15
%17 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([49 x i8], [49 x i8]* @.str.1, i64 0, i64 0), i32 %12, i32 %14, i32 %16)
br label %20
18: ; preds = %0
%19 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([15 x i8], [15 x i8]* @.str.2, i64 0, i64 0))
br label %20
20: ; preds = %18, %10
%21 = load i32, i32* %3
%22 = call i32 @sclose(i32 %21)
%23 = getelementptr inbounds [3 x i32], [3 x i32]* %2, i64 0, i64 0
store i32 0, i32* %23
%24 = getelementptr inbounds [3 x i32], [3 x i32]* %2, i64 0, i64 1
store i32 0, i32* %24
%25 = getelementptr inbounds [3 x i32], [3 x i32]* %2, i64 0, i64 2
store i32 0, i32* %25
%26 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.3, i64 0, i64 0))
%27 = call i32 @sopen_adc(i32 0, float 1.000000e+00)
store i32 %27, i32* %3
%28 = load i32, i32* %3
%29 = getelementptr inbounds [3 x i32], [3 x i32]* %2, i64 0, i64 0
%30 = call i64 @sread(i32 %28, i32* %29)
%31 = icmp eq i64 %30, 0
br i1 %31, label %32, label %36
32: ; preds = %20
%33 = getelementptr inbounds [3 x i32], [3 x i32]* %2, i64 0, i64 0
%34 = load i32, i32* %33
%35 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([38 x i8], [38 x i8]* @.str.4, i64 0, i64 0), i32 %34)
br label %38
36: ; preds = %20
%37 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([15 x i8], [15 x i8]* @.str.2, i64 0, i64 0))
br label %38
38: ; preds = %36, %32
%39 = load i32, i32* %3
%40 = call i32 @sclose(i32 %39)
%41 = getelementptr inbounds [3 x i32], [3 x i32]* %2, i64 0, i64 0
store i32 0, i32* %41
%42 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([16 x i8], [16 x i8]* @.str.5, i64 0, i64 0))
%43 = call i32 @sopen(i32 4)
store i32 %43, i32* %3
%44 = load i32, i32* %3
%45 = getelementptr inbounds [3 x i32], [3 x i32]* %2, i64 0, i64 0
%46 = call i64 @sread(i32 %44, i32* %45)
%47 = icmp eq i64 %46, 0
br i1 %47, label %48, label %52
48: ; preds = %38
%49 = getelementptr inbounds [3 x i32], [3 x i32]* %2, i64 0, i64 0
%50 = load i32, i32* %49
%51 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([38 x i8], [38 x i8]* @.str.4, i64 0, i64 0), i32 %50)
br label %54
52: ; preds = %38
%53 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([15 x i8], [15 x i8]* @.str.2, i64 0, i64 0))
br label %54
54: ; preds = %52, %48
%55 = load i32, i32* %3
%56 = call i32 @sclose(i32 %55)
%57 = getelementptr inbounds [3 x i32], [3 x i32]* %2, i64 0, i64 0
store i32 0, i32* %57
%58 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([14 x i8], [14 x i8]* @.str.6, i64 0, i64 0))
%59 = call i32 @sopen(i32 1)
store i32 %59, i32* %3
%60 = load i32, i32* %3
%61 = getelementptr inbounds [3 x i32], [3 x i32]* %2, i64 0, i64 0
%62 = call i64 @sread(i32 %60, i32* %61)
%63 = icmp eq i64 %62, 0
br i1 %63, label %64, label %68
64: ; preds = %54
%65 = getelementptr inbounds [3 x i32], [3 x i32]* %2, i64 0, i64 0
%66 = load i32, i32* %65
%67 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([38 x i8], [38 x i8]* @.str.4, i64 0, i64 0), i32 %66)
br label %70
68: ; preds = %54
%69 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([15 x i8], [15 x i8]* @.str.2, i64 0, i64 0))
br label %70
70: ; preds = %68, %64
%71 = load i32, i32* %3
%72 = call i32 @sclose(i32 %71)
%73 = getelementptr inbounds [3 x i32], [3 x i32]* %2, i64 0, i64 0
store i32 0, i32* %73
%74 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([11 x i8], [11 x i8]* @.str.7, i64 0, i64 0))
%75 = call i32 @sopen(i32 2)
store i32 %75, i32* %3
%76 = load i32, i32* %3
%77 = getelementptr inbounds [3 x i32], [3 x i32]* %2, i64 0, i64 0
%78 = call i64 @sread(i32 %76, i32* %77)
%79 = icmp eq i64 %78, 0
br i1 %79, label %80, label %84
80: ; preds = %70
%81 = getelementptr inbounds [3 x i32], [3 x i32]* %2, i64 0, i64 0
%82 = load i32, i32* %81
%83 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([38 x i8], [38 x i8]* @.str.4, i64 0, i64 0), i32 %82)
br label %86
84: ; preds = %70
%85 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([15 x i8], [15 x i8]* @.str.2, i64 0, i64 0))
br label %86
86: ; preds = %84, %80
%87 = load i32, i32* %3
%88 = call i32 @sclose(i32 %87)
%89 = load i32, i32* %1
ret i32 %89
}

LLVM IR (-O2):
@.str.1 = [49 x i8] c"\09Read successful. Data received: %i, %i and %i\0A\0A\00"
@.str.4 = [38 x i8] c"\09Read successful. Data received: %i\0A\0A\00"
@str = [15 x i8] c"Accelerometer:\00"
@str.9 = [5 x i8] c"ADC:\00"
@str.11 = [15 x i8] c"Ambient light:\00"
@str.13 = [13 x i8] c"Temperature:\00"
@str.15 = [10 x i8] c"Humidity:\00"
@str.16 = [14 x i8] c"\09Read failed\0A\00"
define i32 @main() {
%1 = alloca [3 x i32]
%2 = bitcast [3 x i32]* %1 to i8*
%3 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([15 x i8], [15 x i8]* @str, i64 0, i64 0))
%4 = tail call i32 @sopen(i32 3)
%5 = getelementptr inbounds [3 x i32], [3 x i32]* %1, i64 0, i64 0
%6 = call i64 @sread(i32 %4, i32* %5)
%7 = icmp eq i64 %6, 0
br i1 %7, label %8, label %15
8: ; preds = %0
%9 = load i32, i32* %5
%10 = getelementptr inbounds [3 x i32], [3 x i32]* %1, i64 0, i64 1
%11 = load i32, i32* %10
%12 = getelementptr inbounds [3 x i32], [3 x i32]* %1, i64 0, i64 2
%13 = load i32, i32* %12
%14 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([49 x i8], [49 x i8]* @.str.1, i64 0, i64 0), i32 %9, i32 %11, i32 %13)
br label %17
15: ; preds = %0
%16 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([14 x i8], [14 x i8]* @str.16, i64 0, i64 0))
br label %17
17: ; preds = %15, %8
%18 = call i32 @sclose(i32 %4)
store i32 0, i32* %5
%19 = getelementptr inbounds [3 x i32], [3 x i32]* %1, i64 0, i64 1
store i32 0, i32* %19
%20 = getelementptr inbounds [3 x i32], [3 x i32]* %1, i64 0, i64 2
store i32 0, i32* %20
%21 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([5 x i8], [5 x i8]* @str.9, i64 0, i64 0))
%22 = call i32 @sopen_adc(i32 0, float 1.000000e+00)
%23 = call i64 @sread(i32 %22, i32* %5)
%24 = icmp eq i64 %23, 0
br i1 %24, label %25, label %28
25: ; preds = %17
%26 = load i32, i32* %5
%27 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([38 x i8], [38 x i8]* @.str.4, i64 0, i64 0), i32 %26)
br label %30
28: ; preds = %17
%29 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([14 x i8], [14 x i8]* @str.16, i64 0, i64 0))
br label %30
30: ; preds = %28, %25
%31 = call i32 @sclose(i32 %22)
store i32 0, i32* %5
%32 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([15 x i8], [15 x i8]* @str.11, i64 0, i64 0))
%33 = call i32 @sopen(i32 4)
%34 = call i64 @sread(i32 %33, i32* %5)
%35 = icmp eq i64 %34, 0
br i1 %35, label %36, label %39
36: ; preds = %30
%37 = load i32, i32* %5
%38 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([38 x i8], [38 x i8]* @.str.4, i64 0, i64 0), i32 %37)
br label %41
39: ; preds = %30
%40 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([14 x i8], [14 x i8]* @str.16, i64 0, i64 0))
br label %41
41: ; preds = %39, %36
%42 = call i32 @sclose(i32 %33)
store i32 0, i32* %5
%43 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([13 x i8], [13 x i8]* @str.13, i64 0, i64 0))
%44 = call i32 @sopen(i32 1)
%45 = call i64 @sread(i32 %44, i32* %5)
%46 = icmp eq i64 %45, 0
br i1 %46, label %47, label %50
47: ; preds = %41
%48 = load i32, i32* %5
%49 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([38 x i8], [38 x i8]* @.str.4, i64 0, i64 0), i32 %48)
br label %52
50: ; preds = %41
%51 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([14 x i8], [14 x i8]* @str.16, i64 0, i64 0))
br label %52
52: ; preds = %50, %47
%53 = call i32 @sclose(i32 %44)
store i32 0, i32* %5
%54 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([10 x i8], [10 x i8]* @str.15, i64 0, i64 0))
%55 = call i32 @sopen(i32 2)
%56 = call i64 @sread(i32 %55, i32* %5)
%57 = icmp eq i64 %56, 0
br i1 %57, label %58, label %61
58: ; preds = %52
%59 = load i32, i32* %5
%60 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([38 x i8], [38 x i8]* @.str.4, i64 0, i64 0), i32 %59)
br label %63
61: ; preds = %52
%62 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([14 x i8], [14 x i8]* @str.16, i64 0, i64 0))
br label %63
63: ; preds = %61, %58
%64 = call i32 @sclose(i32 %55)
ret i32 0
}