#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 */
typedef scalar_t__ pid_t;

/* Variables and functions */
int /*<<< orphan*/ execlp(char *, char *, int /*<<< orphan*/ *);
int /*<<< orphan*/ exit(int);
scalar_t__ fork();
int /*<<< orphan*/ printf(char *);
int /*<<< orphan*/ wait(int /*<<< orphan*/);
int Laser_serial_config(void) {
  pid_t pid = fork();
  if (pid < 0) {
    printf("A fork error in Laser_serial_config has occurred.\n");
    exit(-1);
  } else {
    if (pid == 0) {
      execlp("./laser/serial_conf.sh", "laser/serial_conf.sh", NULL);
      printf("laser serial config script error\n");
      return -1;
    } else {
      wait(0);
    }
  }
  return 0;
}


x86 assembly (clang, -O0):
<Laser_serial_config>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
mov    $0x0,%al
call   1070 <fork@plt>
mov    %rax,-0x10(%rbp)
cmpq   $0x0,-0x10(%rbp)
jge    1184 <Laser_serial_config+0x34>
lea    0xe8b(%rip),%rdi
call   1030 <printf@plt>
mov    $0xffffffff,%edi
call   1040 <exit@plt>
cmpq   $0x0,-0x10(%rbp)
jne    11be <Laser_serial_config+0x6e>
lea    0xe9d(%rip),%rdi
lea    0xe98(%rip),%rsi
xor    %eax,%eax
mov    %eax,%edx
call   1050 <execlp@plt>
lea    0xe9d(%rip),%rdi
call   1030 <printf@plt>
movl   $0xffffffff,-0x4(%rbp)
jmp    11d1 <Laser_serial_config+0x81>
xor    %edi,%edi
call   1060 <wait@plt>
jmp    11ca <Laser_serial_config+0x7a>
movl   $0x0,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x10,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<Laser_serial_config>:
push   %rbx
xor    %eax,%eax
call   1070 <fork@plt>
test   %rax,%rax
js     1194 <Laser_serial_config+0x44>
je     116a <Laser_serial_config+0x1a>
xor    %ebx,%ebx
xor    %edi,%edi
call   1060 <wait@plt>
jmp    1190 <Laser_serial_config+0x40>
lea    0xe8f(%rip),%rdi
lea    0xe8a(%rip),%rsi
xor    %edx,%edx
call   1050 <execlp@plt>
lea    0xe91(%rip),%rdi
call   1030 <puts@plt>
mov    $0xffffffff,%ebx
mov    %ebx,%eax
pop    %rbx
ret
lea    0xe9d(%rip),%rdi
call   1030 <puts@plt>
mov    $0xffffffff,%edi
call   1040 <exit@plt>

LLVM IR (-O0):
@.str = [51 x i8] c"A fork error in Laser_serial_config has occurred.\0A\00"
@.str.1 = [23 x i8] c"./laser/serial_conf.sh\00"
@.str.2 = [21 x i8] c"laser/serial_conf.sh\00"
@.str.3 = [34 x i8] c"laser serial config script error\0A\00"
define i32 @Laser_serial_config() {
%1 = alloca i32
%2 = alloca i64
%3 = call i64 (...) @fork()
store i64 %3, i64* %2
%4 = load i64, i64* %2
%5 = icmp slt i64 %4, 0
br i1 %5, label %6, label %9
6: ; preds = %0
%7 = call i32 @printf(i8* getelementptr inbounds ([51 x i8], [51 x i8]* @.str, i64 0, i64 0))
%8 = call i32 @exit(i32 -1)
unreachable
9: ; preds = %0
%10 = load i64, i64* %2
%11 = icmp eq i64 %10, 0
br i1 %11, label %12, label %15
12: ; preds = %9
%13 = call i32 @execlp(i8* getelementptr inbounds ([23 x i8], [23 x i8]* @.str.1, i64 0, i64 0), i8* getelementptr inbounds ([21 x i8], [21 x i8]* @.str.2, i64 0, i64 0), i32* null)
%14 = call i32 @printf(i8* getelementptr inbounds ([34 x i8], [34 x i8]* @.str.3, i64 0, i64 0))
store i32 -1, i32* %1
br label %19
15: ; preds = %9
%16 = call i32 @wait(i32 0)
br label %17
17: ; preds = %15
br label %18
18: ; preds = %17
store i32 0, i32* %1
br label %19
19: ; preds = %18, %12
%20 = load i32, i32* %1
ret i32 %20
}

LLVM IR (-O2):
@.str.1 = [23 x i8] c"./laser/serial_conf.sh\00"
@.str.2 = [21 x i8] c"laser/serial_conf.sh\00"
@str = [33 x i8] c"laser serial config script error\00"
@str.4 = [50 x i8] c"A fork error in Laser_serial_config has occurred.\00"
define i32 @Laser_serial_config() {
%1 = tail call i64 (...) @fork()
%2 = icmp slt i64 %1, 0
br i1 %2, label %3, label %6
3: ; preds = %0
%4 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([50 x i8], [50 x i8]* @str.4, i64 0, i64 0))
%5 = tail call i32 @exit(i32 -1)
unreachable
6: ; preds = %0
%7 = icmp eq i64 %1, 0
br i1 %7, label %8, label %11
8: ; preds = %6
%9 = tail call i32 @execlp(i8* getelementptr inbounds ([23 x i8], [23 x i8]* @.str.1, i64 0, i64 0), i8* getelementptr inbounds ([21 x i8], [21 x i8]* @.str.2, i64 0, i64 0), i32* null)
%10 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([33 x i8], [33 x i8]* @str, i64 0, i64 0))
br label %13
11: ; preds = %6
%12 = tail call i32 @wait(i32 0)
br label %13
13: ; preds = %11, %8
%14 = phi i32 [ -1, %8 ], [ 0, %11 ]
ret i32 %14
}