#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*/ close(int);
int /*<<< orphan*/ exit(int);
int /*<<< orphan*/ printf(char *);
int ser_autodetect(int);
int main() {
  int rv;
  rv = ser_autodetect(9600);
  switch (rv) {
  case -1:
    printf("Tests skipped, no arduinos detected.\n");
    exit(77);
    break;
  case -2:
    printf("Test skipped, No serial usb devices detected\n");
    exit(77);
  }
  close(rv);
  printf("Test passed.\n");
  exit(0);
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
movl   $0x0,-0x4(%rbp)
mov    $0x2580,%edi
call   1050 <ser_autodetect@plt>
mov    %eax,-0x8(%rbp)
mov    -0x8(%rbp),%eax
mov    %eax,-0xc(%rbp)
sub    $0xfffffffe,%eax
je     1197 <main+0x57>
jmp    1170 <main+0x30>
mov    -0xc(%rbp),%eax
sub    $0xffffffff,%eax
jne    11ad <main+0x6d>
jmp    1181 <main+0x41>
lea    0xe78(%rip),%rdi
call   1030 <printf@plt>
mov    $0x4d,%edi
call   1060 <exit@plt>
lea    0xe88(%rip),%rdi
call   1030 <printf@plt>
mov    $0x4d,%edi
call   1060 <exit@plt>
mov    -0x8(%rbp),%edi
call   1040 <close@plt>
lea    0xe98(%rip),%rdi
call   1030 <printf@plt>
xor    %edi,%edi
call   1060 <exit@plt>

x86 assembly (clang, -O2):
<main>:
push   %rax
mov    $0x2580,%edi
call   1050 <ser_autodetect@plt>
cmp    $0xfffffffe,%eax
je     115e <main+0x1e>
cmp    $0xffffffff,%eax
jne    1174 <main+0x34>
lea    0xed1(%rip),%rdi
jmp    1165 <main+0x25>
lea    0xe9b(%rip),%rdi
call   1030 <puts@plt>
mov    $0x4d,%edi
call   1060 <exit@plt>
mov    %eax,%edi
call   1040 <close@plt>
lea    0xed0(%rip),%rdi
call   1030 <puts@plt>
xor    %edi,%edi
call   1060 <exit@plt>

LLVM IR (-O0):
@.str = [38 x i8] c"Tests skipped, no arduinos detected.\0A\00"
@.str.1 = [46 x i8] c"Test skipped, No serial usb devices detected\0A\00"
@.str.2 = [14 x i8] c"Test passed.\0A\00"
define i32 @main() {
%1 = alloca i32
%2 = alloca i32
store i32 0, i32* %1
%3 = call i32 @ser_autodetect(i32 9600)
store i32 %3, i32* %2
%4 = load i32, i32* %2
switch i32 %4, label %11 [
i32 -1, label %5
i32 -2, label %8
]
5: ; preds = %0
%6 = call i32 @printf(i8* getelementptr inbounds ([38 x i8], [38 x i8]* @.str, i64 0, i64 0))
%7 = call i32 @exit(i32 77)
unreachable
8: ; preds = %0
%9 = call i32 @printf(i8* getelementptr inbounds ([46 x i8], [46 x i8]* @.str.1, i64 0, i64 0))
%10 = call i32 @exit(i32 77)
unreachable
11: ; preds = %0
%12 = load i32, i32* %2
%13 = call i32 @close(i32 %12)
%14 = call i32 @printf(i8* getelementptr inbounds ([14 x i8], [14 x i8]* @.str.2, i64 0, i64 0))
%15 = call i32 @exit(i32 0)
unreachable
}

LLVM IR (-O2):
@str = [45 x i8] c"Test skipped, No serial usb devices detected\00"
@str.3 = [37 x i8] c"Tests skipped, no arduinos detected.\00"
@str.4 = [13 x i8] c"Test passed.\00"
define i32 @main() {
%1 = tail call i32 @ser_autodetect(i32 9600)
switch i32 %1, label %8 [
i32 -1, label %2
i32 -2, label %5
]
2: ; preds = %0
%3 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([37 x i8], [37 x i8]* @str.3, i64 0, i64 0))
%4 = tail call i32 @exit(i32 77)
unreachable
5: ; preds = %0
%6 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([45 x i8], [45 x i8]* @str, i64 0, i64 0))
%7 = tail call i32 @exit(i32 77)
unreachable
8: ; preds = %0
%9 = tail call i32 @close(i32 %1)
%10 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([13 x i8], [13 x i8]* @str.4, i64 0, i64 0))
%11 = tail call i32 @exit(i32 0)
unreachable
}