#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 */
struct common {
  int dummy;
};

/* Variables and functions */
int /*<<< orphan*/ lefttoright(struct common *);
int /*<<< orphan*/ perror(char *);
int /*<<< orphan*/ righttoleft(struct common *);
void car(int direction, struct common *shared) {
  if (direction != 1 && direction != 2)
    perror("ERROR: INVALID ARGUMENT GIVEN TO CAR PROCESS");
  if (direction == 1)
    lefttoright(shared);
  else
    righttoleft(shared);
}


x86 assembly (clang, -O0):
<car>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
mov    %edi,-0x4(%rbp)
mov    %rsi,-0x10(%rbp)
cmpl   $0x1,-0x4(%rbp)
je     115f <car+0x2f>
cmpl   $0x2,-0x4(%rbp)
je     115f <car+0x2f>
lea    0xea6(%rip),%rdi
call   1040 <perror@plt>
cmpl   $0x1,-0x4(%rbp)
jne    1177 <car+0x47>
mov    -0x10(%rbp),%rdi
call   1030 <lefttoright@plt>
jmp    1180 <car+0x50>
mov    -0x10(%rbp),%rdi
call   1050 <righttoleft@plt>
add    $0x10,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<car>:
push   %rbx
mov    %rsi,%rbx
lea    -0x3(%rdi),%eax
cmp    $0xfffffffd,%eax
jbe    114a <car+0x1a>
cmp    $0x1,%edi
jne    1156 <car+0x26>
mov    %rbx,%rdi
pop    %rbx
jmp    1030 <lefttoright@plt>
lea    0xeaf(%rip),%rdi
call   1040 <perror@plt>
mov    %rbx,%rdi
pop    %rbx
jmp    1050 <righttoleft@plt>

LLVM IR (-O0):
%struct.common = type { i32 }
@.str = [45 x i8] c"ERROR: INVALID ARGUMENT GIVEN TO CAR PROCESS\00"
define void @car(i32 %0, %struct.common* %1) {
%3 = alloca i32
%4 = alloca %struct.common*
store i32 %0, i32* %3
store %struct.common* %1, %struct.common** %4
%5 = load i32, i32* %3
%6 = icmp ne i32 %5, 1
br i1 %6, label %7, label %12
7: ; preds = %2
%8 = load i32, i32* %3
%9 = icmp ne i32 %8, 2
br i1 %9, label %10, label %12
10: ; preds = %7
%11 = call i32 @perror(i8* getelementptr inbounds ([45 x i8], [45 x i8]* @.str, i64 0, i64 0))
br label %12
12: ; preds = %10, %7, %2
%13 = load i32, i32* %3
%14 = icmp eq i32 %13, 1
br i1 %14, label %15, label %18
15: ; preds = %12
%16 = load %struct.common*, %struct.common** %4
%17 = call i32 @lefttoright(%struct.common* %16)
br label %21
18: ; preds = %12
%19 = load %struct.common*, %struct.common** %4
%20 = call i32 @righttoleft(%struct.common* %19)
br label %21
21: ; preds = %18, %15
ret void
}

LLVM IR (-O2):
%struct.common = type { i32 }
@.str = [45 x i8] c"ERROR: INVALID ARGUMENT GIVEN TO CAR PROCESS\00"
define void @car(i32 %0, %struct.common* %1) {
%3 = add i32 %0, -3
%4 = icmp ult i32 %3, -2
br i1 %4, label %5, label %7
5: ; preds = %2
%6 = tail call i32 @perror(i8* getelementptr inbounds ([45 x i8], [45 x i8]* @.str, i64 0, i64 0))
br label %11
7: ; preds = %2
%8 = icmp eq i32 %0, 1
br i1 %8, label %9, label %11
9: ; preds = %7
%10 = tail call i32 @lefttoright(%struct.common* %1)
br label %13
11: ; preds = %5, %7
%12 = tail call i32 @righttoleft(%struct.common* %1)
br label %13
13: ; preds = %11, %9
ret void
}