#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*/ exit(int);
int /*<<< orphan*/ fprintf(int /*<<< orphan*/, char *, unsigned char);
unsigned char gfMult2(unsigned char);
unsigned char gfMult3(unsigned char);
int /*<<< orphan*/ stderr;
unsigned char gfMult(unsigned char a, unsigned char x) {
  switch (a) {
  case 1:
    return x;
    break;
  case 2:
    return gfMult2(x);
    break;
  case 3:
    return gfMult3(x);
    break;
  default:
    fprintf(stderr, "gfMult: INVALID CONSTANT --- A = %d\n", a);
    exit(1);
    break;
  }
}


x86 assembly (clang, -O0):
<gfMult>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
mov    %sil,%al
mov    %dil,%cl
mov    %cl,-0x2(%rbp)
mov    %al,-0x3(%rbp)
movzbl -0x2(%rbp),%eax
mov    %eax,-0x8(%rbp)
sub    $0x1,%eax
je     118b <gfMult+0x4b>
jmp    1169 <gfMult+0x29>
mov    -0x8(%rbp),%eax
sub    $0x2,%eax
je     1196 <gfMult+0x56>
jmp    117a <gfMult+0x3a>
mov    -0x8(%rbp),%eax
sub    $0x3,%eax
je     11a7 <gfMult+0x67>
jmp    11b8 <gfMult+0x78>
mov    -0x3(%rbp),%al
mov    %al,-0x1(%rbp)
jmp    11db <gfMult+0x9b>
movzbl -0x3(%rbp),%edi
call   1030 <gfMult2@plt>
mov    %al,-0x1(%rbp)
jmp    11db <gfMult+0x9b>
movzbl -0x3(%rbp),%edi
call   1050 <gfMult3@plt>
mov    %al,-0x1(%rbp)
jmp    11db <gfMult+0x9b>
mov    0x2e21(%rip),%rax
mov    (%rax),%edi
lea    0xe38(%rip),%rsi
movzbl -0x2(%rbp),%edx
call   1040 <fprintf@plt>
mov    $0x1,%edi
call   1060 <exit@plt>
movzbl -0x1(%rbp),%eax
add    $0x10,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<gfMult>:
cmp    $0x1,%dil
je     115b <gfMult+0x1b>
cmp    $0x3,%dil
je     115e <gfMult+0x1e>
cmp    $0x2,%dil
jne    1167 <gfMult+0x27>
movzbl %sil,%edi
jmp    1030 <gfMult2@plt>
mov    %esi,%eax
ret
movzbl %sil,%edi
jmp    1050 <gfMult3@plt>
push   %rax
mov    0x2e71(%rip),%rax
mov    (%rax),%eax
movzbl %dil,%edx
lea    0xe84(%rip),%rsi
mov    %eax,%edi
call   1040 <fprintf@plt>
mov    $0x1,%edi
call   1060 <exit@plt>

LLVM IR (-O0):
@stderr = global i32 0
@.str = [37 x i8] c"gfMult: INVALID CONSTANT --- A = %d\0A\00"
define zeroext i8 @gfMult(i8 zeroext %0, i8 zeroext %1) {
%3 = alloca i8
%4 = alloca i8
%5 = alloca i8
store i8 %0, i8* %4
store i8 %1, i8* %5
%6 = load i8, i8* %4
%7 = zext i8 %6 to i32
switch i32 %7, label %16 [
i32 1, label %8
i32 2, label %10
i32 3, label %13
]
8: ; preds = %2
%9 = load i8, i8* %5
store i8 %9, i8* %3
br label %21
10: ; preds = %2
%11 = load i8, i8* %5
%12 = call zeroext i8 @gfMult2(i8 zeroext %11)
store i8 %12, i8* %3
br label %21
13: ; preds = %2
%14 = load i8, i8* %5
%15 = call zeroext i8 @gfMult3(i8 zeroext %14)
store i8 %15, i8* %3
br label %21
16: ; preds = %2
%17 = load i32, i32* @stderr
%18 = load i8, i8* %4
%19 = call i32 @fprintf(i32 %17, i8* getelementptr inbounds ([37 x i8], [37 x i8]* @.str, i64 0, i64 0), i8 zeroext %18)
%20 = call i32 @exit(i32 1)
unreachable
21: ; preds = %13, %10, %8
%22 = load i8, i8* %3
ret i8 %22
}

LLVM IR (-O2):
@stderr = global i32 0
@.str = [37 x i8] c"gfMult: INVALID CONSTANT --- A = %d\0A\00"
define zeroext i8 @gfMult(i8 zeroext %0, i8 zeroext %1) {
switch i8 %0, label %7 [
i8 1, label %11
i8 2, label %3
i8 3, label %5
]
3: ; preds = %2
%4 = tail call zeroext i8 @gfMult2(i8 zeroext %1)
br label %11
5: ; preds = %2
%6 = tail call zeroext i8 @gfMult3(i8 zeroext %1)
br label %11
7: ; preds = %2
%8 = load i32, i32* @stderr
%9 = tail call i32 @fprintf(i32 %8, i8* getelementptr inbounds ([37 x i8], [37 x i8]* @.str, i64 0, i64 0), i8 zeroext %0)
%10 = tail call i32 @exit(i32 1)
unreachable
11: ; preds = %2, %5, %3
%12 = phi i8 [ %6, %5 ], [ %4, %3 ], [ %1, %2 ]
ret i8 %12
}