#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 triple {
  int dummy;
};
struct compile_state {
  int dummy;
};

/* Variables and functions */
int /*<<< orphan*/ error(struct compile_state *, struct triple *, char *);
int /*<<< orphan*/ is_pointer(struct triple *);
int /*<<< orphan*/ mk_add_expr(struct compile_state *, struct triple *,
                               struct triple *);
struct triple *mk_deref_expr(struct compile_state *, int /*<<< orphan*/);
struct triple *read_expr(struct compile_state *, struct triple *);
struct triple *mk_sudirript_expr(struct compile_state *state,
                                 struct triple *left, struct triple *right) {
  left = read_expr(state, left);
  right = read_expr(state, right);
  if (!is_pointer(left) && !is_pointer(right)) {
    error(state, left, "sudirripted value is not a pointer");
  }
  return mk_deref_expr(state, mk_add_expr(state, left, right));
}


x86 assembly (clang, -O0):
<mk_sudirript_expr>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %rdi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
mov    %rdx,-0x18(%rbp)
mov    -0x8(%rbp),%rdi
mov    -0x10(%rbp),%rsi
call   1030 <read_expr@plt>
mov    %rax,-0x10(%rbp)
mov    -0x8(%rbp),%rdi
mov    -0x18(%rbp),%rsi
call   1030 <read_expr@plt>
mov    %rax,-0x18(%rbp)
mov    -0x10(%rbp),%rdi
call   1070 <is_pointer@plt>
cmp    $0x0,%eax
jne    11be <mk_sudirript_expr+0x6e>
mov    -0x18(%rbp),%rdi
call   1070 <is_pointer@plt>
cmp    $0x0,%eax
jne    11be <mk_sudirript_expr+0x6e>
mov    -0x8(%rbp),%rdi
mov    -0x10(%rbp),%rsi
lea    0xe47(%rip),%rdx
call   1060 <error@plt>
mov    -0x8(%rbp),%rax
mov    %rax,-0x20(%rbp)
mov    -0x8(%rbp),%rdi
mov    -0x10(%rbp),%rsi
mov    -0x18(%rbp),%rdx
call   1040 <mk_add_expr@plt>
mov    -0x20(%rbp),%rdi
mov    %eax,%esi
call   1050 <mk_deref_expr@plt>
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<mk_sudirript_expr>:
push   %r15
push   %r14
push   %rbx
mov    %rdx,%r15
mov    %rdi,%rbx
call   1030 <read_expr@plt>
mov    %rax,%r14
mov    %rbx,%rdi
mov    %r15,%rsi
call   1030 <read_expr@plt>
mov    %rax,%r15
mov    %r14,%rdi
call   1070 <is_pointer@plt>
test   %eax,%eax
jne    119b <mk_sudirript_expr+0x4b>
mov    %r15,%rdi
call   1070 <is_pointer@plt>
test   %eax,%eax
jne    119b <mk_sudirript_expr+0x4b>
lea    0xe70(%rip),%rdx
mov    %rbx,%rdi
mov    %r14,%rsi
call   1060 <error@plt>
mov    %rbx,%rdi
mov    %r14,%rsi
mov    %r15,%rdx
call   1040 <mk_add_expr@plt>
mov    %rbx,%rdi
mov    %eax,%esi
pop    %rbx
pop    %r14
pop    %r15
jmp    1050 <mk_deref_expr@plt>

LLVM IR (-O0):
%struct.compile_state = type { i32 }
%struct.triple = type { i32 }
@.str = [35 x i8] c"sudirripted value is not a pointer\00"
define %struct.triple* @mk_sudirript_expr(%struct.compile_state* %0, %struct.triple* %1, %struct.triple* %2) {
%4 = alloca %struct.compile_state*
%5 = alloca %struct.triple*
%6 = alloca %struct.triple*
store %struct.compile_state* %0, %struct.compile_state** %4
store %struct.triple* %1, %struct.triple** %5
store %struct.triple* %2, %struct.triple** %6
%7 = load %struct.compile_state*, %struct.compile_state** %4
%8 = load %struct.triple*, %struct.triple** %5
%9 = call %struct.triple* @read_expr(%struct.compile_state* %7, %struct.triple* %8)
store %struct.triple* %9, %struct.triple** %5
%10 = load %struct.compile_state*, %struct.compile_state** %4
%11 = load %struct.triple*, %struct.triple** %6
%12 = call %struct.triple* @read_expr(%struct.compile_state* %10, %struct.triple* %11)
store %struct.triple* %12, %struct.triple** %6
%13 = load %struct.triple*, %struct.triple** %5
%14 = call i32 @is_pointer(%struct.triple* %13)
%15 = icmp ne i32 %14, 0
br i1 %15, label %24, label %16
16: ; preds = %3
%17 = load %struct.triple*, %struct.triple** %6
%18 = call i32 @is_pointer(%struct.triple* %17)
%19 = icmp ne i32 %18, 0
br i1 %19, label %24, label %20
20: ; preds = %16
%21 = load %struct.compile_state*, %struct.compile_state** %4
%22 = load %struct.triple*, %struct.triple** %5
%23 = call i32 @error(%struct.compile_state* %21, %struct.triple* %22, i8* getelementptr inbounds ([35 x i8], [35 x i8]* @.str, i64 0, i64 0))
br label %24
24: ; preds = %20, %16, %3
%25 = load %struct.compile_state*, %struct.compile_state** %4
%26 = load %struct.compile_state*, %struct.compile_state** %4
%27 = load %struct.triple*, %struct.triple** %5
%28 = load %struct.triple*, %struct.triple** %6
%29 = call i32 @mk_add_expr(%struct.compile_state* %26, %struct.triple* %27, %struct.triple* %28)
%30 = call %struct.triple* @mk_deref_expr(%struct.compile_state* %25, i32 %29)
ret %struct.triple* %30
}

LLVM IR (-O2):
%struct.compile_state = type { i32 }
%struct.triple = type { i32 }
@.str = [35 x i8] c"sudirripted value is not a pointer\00"
define %struct.triple* @mk_sudirript_expr(%struct.compile_state* %0, %struct.triple* %1, %struct.triple* %2) {
%4 = tail call %struct.triple* @read_expr(%struct.compile_state* %0, %struct.triple* %1)
%5 = tail call %struct.triple* @read_expr(%struct.compile_state* %0, %struct.triple* %2)
%6 = tail call i32 @is_pointer(%struct.triple* %4)
%7 = icmp eq i32 %6, 0
br i1 %7, label %8, label %13
8: ; preds = %3
%9 = tail call i32 @is_pointer(%struct.triple* %5)
%10 = icmp eq i32 %9, 0
br i1 %10, label %11, label %13
11: ; preds = %8
%12 = tail call i32 @error(%struct.compile_state* %0, %struct.triple* %4, i8* getelementptr inbounds ([35 x i8], [35 x i8]* @.str, i64 0, i64 0))
br label %13
13: ; preds = %11, %8, %3
%14 = tail call i32 @mk_add_expr(%struct.compile_state* %0, %struct.triple* %4, %struct.triple* %5)
%15 = tail call %struct.triple* @mk_deref_expr(%struct.compile_state* %0, i32 %14)
ret %struct.triple* %15
}