#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*/ gen_call(char *);
int /*<<< orphan*/ gen_multiply_by_two();
int /*<<< orphan*/ newline();
int /*<<< orphan*/ output_immediate(int);
int /*<<< orphan*/ output_with_tab(char *);
void gen_multiply(int type, int size) {
  switch (type) {
  case (2 << 2):
  case ((2 << 2) + 1):
    gen_multiply_by_two();
    break;
  case 2:
    output_with_tab("ldy ");
    output_immediate(size);
    newline();
    gen_call("__muli ");
    newline();
    break;
  default:
    break;
  }
}


x86 assembly (clang, -O0):
<gen_multiply>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
mov    %edi,-0x4(%rbp)
mov    %esi,-0x8(%rbp)
mov    -0x4(%rbp),%eax
mov    %eax,-0xc(%rbp)
sub    $0x2,%eax
je     1192 <gen_multiply+0x42>
jmp    1172 <gen_multiply+0x22>
mov    -0xc(%rbp),%eax
add    $0xfffffff8,%eax
sub    $0x1,%eax
ja     11c5 <gen_multiply+0x75>
jmp    1186 <gen_multiply+0x36>
mov    $0x0,%al
call   1070 <gen_multiply_by_two@plt>
jmp    11ca <gen_multiply+0x7a>
lea    0xe67(%rip),%rdi
call   1040 <output_with_tab@plt>
mov    -0x8(%rbp),%edi
call   1050 <output_immediate@plt>
mov    $0x0,%al
call   1030 <newline@plt>
lea    0xe51(%rip),%rdi
call   1060 <gen_call@plt>
mov    $0x0,%al
call   1030 <newline@plt>
jmp    11ca <gen_multiply+0x7a>
jmp    11ca <gen_multiply+0x7a>
add    $0x10,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<gen_multiply>:
lea    -0x8(%rdi),%eax
cmp    $0x2,%eax
jae    115f <gen_multiply+0xf>
xor    %eax,%eax
jmp    1070 <gen_multiply_by_two@plt>
cmp    $0x2,%edi
jne    1195 <gen_multiply+0x45>
push   %rbx
mov    %esi,%ebx
lea    0xe92(%rip),%rdi
call   1040 <output_with_tab@plt>
mov    %ebx,%edi
call   1050 <output_immediate@plt>
xor    %eax,%eax
call   1030 <newline@plt>
lea    0xe7d(%rip),%rdi
call   1060 <gen_call@plt>
xor    %eax,%eax
pop    %rbx
jmp    1030 <newline@plt>
ret

LLVM IR (-O0):
@.str = [5 x i8] c"ldy \00"
@.str.1 = [8 x i8] c"__muli \00"
define void @gen_multiply(i32 %0, i32 %1) {
%3 = alloca i32
%4 = alloca i32
store i32 %0, i32* %3
store i32 %1, i32* %4
%5 = load i32, i32* %3
switch i32 %5, label %15 [
i32 8, label %6
i32 9, label %6
i32 2, label %8
]
6: ; preds = %2, %2
%7 = call i32 (...) @gen_multiply_by_two()
br label %16
8: ; preds = %2
%9 = call i32 @output_with_tab(i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str, i64 0, i64 0))
%10 = load i32, i32* %4
%11 = call i32 @output_immediate(i32 %10)
%12 = call i32 (...) @newline()
%13 = call i32 @gen_call(i8* getelementptr inbounds ([8 x i8], [8 x i8]* @.str.1, i64 0, i64 0))
%14 = call i32 (...) @newline()
br label %16
15: ; preds = %2
br label %16
16: ; preds = %15, %8, %6
ret void
}

LLVM IR (-O2):
@.str = [5 x i8] c"ldy \00"
@.str.1 = [8 x i8] c"__muli \00"
define void @gen_multiply(i32 %0, i32 %1) {
switch i32 %0, label %11 [
i32 8, label %3
i32 9, label %3
i32 2, label %5
]
3: ; preds = %2, %2
%4 = tail call i32 (...) @gen_multiply_by_two()
br label %11
5: ; preds = %2
%6 = tail call i32 @output_with_tab(i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str, i64 0, i64 0))
%7 = tail call i32 @output_immediate(i32 %1)
%8 = tail call i32 (...) @newline()
%9 = tail call i32 @gen_call(i8* getelementptr inbounds ([8 x i8], [8 x i8]* @.str.1, i64 0, i64 0))
%10 = tail call i32 (...) @newline()
br label %11
11: ; preds = %2, %5, %3
ret void
}