#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*/ encode_register(char **, char *);
int /*<<< orphan*/ handle_direct_and_matrix_operands(char *);
int encode_matrix(char *mat_oper, char *matrix_row_operand,
                  char *matrix_col_operand) {
  char *regs[3];
  regs[0] = matrix_row_operand;
  regs[1] = matrix_col_operand;
  if (!(handle_direct_and_matrix_operands(mat_oper))) {
    return 0;
  }
  encode_register(regs, "both");
  return 1;
}


x86 assembly (clang, -O0):
<encode_matrix>:
push   %rbp
mov    %rsp,%rbp
sub    $0x40,%rsp
mov    %rdi,-0x10(%rbp)
mov    %rsi,-0x18(%rbp)
mov    %rdx,-0x20(%rbp)
mov    -0x18(%rbp),%rax
mov    %rax,-0x40(%rbp)
mov    -0x20(%rbp),%rax
mov    %rax,-0x38(%rbp)
mov    -0x10(%rbp),%rdi
call   1030 <handle_direct_and_matrix_operands@plt>
cmp    $0x0,%eax
jne    1162 <encode_matrix+0x42>
movl   $0x0,-0x4(%rbp)
jmp    1179 <encode_matrix+0x59>
lea    -0x40(%rbp),%rdi
lea    0xe93(%rip),%rsi
call   1040 <encode_register@plt>
movl   $0x1,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x40,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<encode_matrix>:
sub    $0x18,%rsp
mov    %rsi,(%rsp)
mov    %rdx,0x8(%rsp)
call   1030 <handle_direct_and_matrix_operands@plt>
test   %eax,%eax
je     114f <encode_matrix+0x2f>
lea    0xec3(%rip),%rsi
mov    %rsp,%rdi
call   1040 <encode_register@plt>
mov    $0x1,%eax
add    $0x18,%rsp
ret
xor    %eax,%eax
add    $0x18,%rsp
ret

LLVM IR (-O0):
@.str = [5 x i8] c"both\00"
define i32 @encode_matrix(i8* %0, i8* %1, i8* %2) {
%4 = alloca i32
%5 = alloca i8*
%6 = alloca i8*
%7 = alloca i8*
%8 = alloca [3 x i8*]
store i8* %0, i8** %5
store i8* %1, i8** %6
store i8* %2, i8** %7
%9 = load i8*, i8** %6
%10 = getelementptr inbounds [3 x i8*], [3 x i8*]* %8, i64 0, i64 0
store i8* %9, i8** %10
%11 = load i8*, i8** %7
%12 = getelementptr inbounds [3 x i8*], [3 x i8*]* %8, i64 0, i64 1
store i8* %11, i8** %12
%13 = load i8*, i8** %5
%14 = call i32 @handle_direct_and_matrix_operands(i8* %13)
%15 = icmp ne i32 %14, 0
br i1 %15, label %17, label %16
16: ; preds = %3
store i32 0, i32* %4
br label %20
17: ; preds = %3
%18 = getelementptr inbounds [3 x i8*], [3 x i8*]* %8, i64 0, i64 0
%19 = call i32 @encode_register(i8** %18, i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str, i64 0, i64 0))
store i32 1, i32* %4
br label %20
20: ; preds = %17, %16
%21 = load i32, i32* %4
ret i32 %21
}

LLVM IR (-O2):
@.str = [5 x i8] c"both\00"
define i32 @encode_matrix(i8* %0, i8* %1, i8* %2) {
%4 = alloca [3 x i8*]
%5 = bitcast [3 x i8*]* %4 to i8*
%6 = getelementptr inbounds [3 x i8*], [3 x i8*]* %4, i64 0, i64 0
store i8* %1, i8** %6
%7 = getelementptr inbounds [3 x i8*], [3 x i8*]* %4, i64 0, i64 1
store i8* %2, i8** %7
%8 = tail call i32 @handle_direct_and_matrix_operands(i8* %0)
%9 = icmp eq i32 %8, 0
br i1 %9, label %12, label %10
10: ; preds = %3
%11 = call i32 @encode_register(i8** %6, i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str, i64 0, i64 0))
br label %12
12: ; preds = %3, %10
%13 = phi i32 [ 1, %10 ], [ 0, %3 ]
ret i32 %13
}