#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*/ cvadd(float *, float *, float *, int);
int /*<<< orphan*/ cvsub(float *, float *, float *, int);
void decode(int codelength, char *code, float *inbuf, float *outbuf,
            int ngates) {
  int c;
  char s;
  for (c = 0; c < 2 * ngates; c++)
    outbuf[c] = 0.0;
  for (c = 0; c < codelength; c++) {
    s = code[c];
    if (s == '+')
      cvadd(outbuf, inbuf + 2 * c, outbuf, ngates);
    else
      cvsub(outbuf, inbuf + 2 * c, outbuf, ngates);
  }
}


x86 assembly (clang, -O0):
<decode>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
mov    %edi,-0x4(%rbp)
mov    %rsi,-0x10(%rbp)
mov    %rdx,-0x18(%rbp)
mov    %rcx,-0x20(%rbp)
mov    %r8d,-0x24(%rbp)
movl   $0x0,-0x28(%rbp)
mov    -0x28(%rbp),%eax
mov    -0x24(%rbp),%ecx
shl    $0x1,%ecx
cmp    %ecx,%eax
jge    1171 <decode+0x51>
mov    -0x20(%rbp),%rax
movslq -0x28(%rbp),%rcx
xorps  %xmm0,%xmm0
movss  %xmm0,(%rax,%rcx,4)
mov    -0x28(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x28(%rbp)
jmp    1142 <decode+0x22>
movl   $0x0,-0x28(%rbp)
mov    -0x28(%rbp),%eax
cmp    -0x4(%rbp),%eax
jge    11fd <decode+0xdd>
mov    -0x10(%rbp),%rax
movslq -0x28(%rbp),%rcx
mov    (%rax,%rcx,1),%al
mov    %al,-0x29(%rbp)
movsbl -0x29(%rbp),%eax
cmp    $0x2b,%eax
jne    11c7 <decode+0xa7>
mov    -0x20(%rbp),%rdi
mov    -0x18(%rbp),%rsi
mov    -0x28(%rbp),%eax
shl    $0x1,%eax
cltq
shl    $0x2,%rax
add    %rax,%rsi
mov    -0x20(%rbp),%rdx
mov    -0x24(%rbp),%ecx
call   1030 <cvadd@plt>
jmp    11ea <decode+0xca>
mov    -0x20(%rbp),%rdi
mov    -0x18(%rbp),%rsi
mov    -0x28(%rbp),%eax
shl    $0x1,%eax
cltq
shl    $0x2,%rax
add    %rax,%rsi
mov    -0x20(%rbp),%rdx
mov    -0x24(%rbp),%ecx
call   1040 <cvsub@plt>
jmp    11ef <decode+0xcf>
mov    -0x28(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x28(%rbp)
jmp    1178 <decode+0x58>
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<decode>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
push   %rax
mov    %r8d,%r14d
mov    %rcx,%r15
mov    %rdx,%rbx
mov    %rsi,%r12
mov    %edi,%ebp
test   %r8d,%r8d
jle    116b <decode+0x3b>
lea    (%r14,%r14,1),%eax
cmp    $0x2,%eax
mov    $0x1,%edx
cmovge %eax,%edx
shl    $0x2,%rdx
mov    %r15,%rdi
xor    %esi,%esi
call   1040 <memset@plt>
test   %ebp,%ebp
jle    11b8 <decode+0x88>
mov    %ebp,%r13d
xor    %ebp,%ebp
jmp    119e <decode+0x6e>
cs nopw 0x0(%rax,%rax,1)
mov    %r15,%rdi
mov    %rbx,%rsi
mov    %r15,%rdx
mov    %r14d,%ecx
call   1050 <cvsub@plt>
add    $0x1,%rbp
add    $0x8,%rbx
cmp    %rbp,%r13
je     11b8 <decode+0x88>
cmpb   $0x2b,(%r12,%rbp,1)
jne    1180 <decode+0x50>
mov    %r15,%rdi
mov    %rbx,%rsi
mov    %r15,%rdx
mov    %r14d,%ecx
call   1030 <cvadd@plt>
jmp    1191 <decode+0x61>
add    $0x8,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
define void @decode(i32 %0, i8* %1, float* %2, float* %3, i32 %4) {
%6 = alloca i32
%7 = alloca i8*
%8 = alloca float*
%9 = alloca float*
%10 = alloca i32
%11 = alloca i32
%12 = alloca i8
store i32 %0, i32* %6
store i8* %1, i8** %7
store float* %2, float** %8
store float* %3, float** %9
store i32 %4, i32* %10
store i32 0, i32* %11
br label %13
13: ; preds = %23, %5
%14 = load i32, i32* %11
%15 = load i32, i32* %10
%16 = mul nsw i32 2, %15
%17 = icmp slt i32 %14, %16
br i1 %17, label %18, label %26
18: ; preds = %13
%19 = load float*, float** %9
%20 = load i32, i32* %11
%21 = sext i32 %20 to i64
%22 = getelementptr inbounds float, float* %19, i64 %21
store float 0.000000e+00, float* %22
br label %23
23: ; preds = %18
%24 = load i32, i32* %11
%25 = add nsw i32 %24, 1
store i32 %25, i32* %11
br label %13
26: ; preds = %13
store i32 0, i32* %11
br label %27
27: ; preds = %61, %26
%28 = load i32, i32* %11
%29 = load i32, i32* %6
%30 = icmp slt i32 %28, %29
br i1 %30, label %31, label %64
31: ; preds = %27
%32 = load i8*, i8** %7
%33 = load i32, i32* %11
%34 = sext i32 %33 to i64
%35 = getelementptr inbounds i8, i8* %32, i64 %34
%36 = load i8, i8* %35
store i8 %36, i8* %12
%37 = load i8, i8* %12
%38 = sext i8 %37 to i32
%39 = icmp eq i32 %38, 43
br i1 %39, label %40, label %50
40: ; preds = %31
%41 = load float*, float** %9
%42 = load float*, float** %8
%43 = load i32, i32* %11
%44 = mul nsw i32 2, %43
%45 = sext i32 %44 to i64
%46 = getelementptr inbounds float, float* %42, i64 %45
%47 = load float*, float** %9
%48 = load i32, i32* %10
%49 = call i32 @cvadd(float* %41, float* %46, float* %47, i32 %48)
br label %60
50: ; preds = %31
%51 = load float*, float** %9
%52 = load float*, float** %8
%53 = load i32, i32* %11
%54 = mul nsw i32 2, %53
%55 = sext i32 %54 to i64
%56 = getelementptr inbounds float, float* %52, i64 %55
%57 = load float*, float** %9
%58 = load i32, i32* %10
%59 = call i32 @cvsub(float* %51, float* %56, float* %57, i32 %58)
br label %60
60: ; preds = %50, %40
br label %61
61: ; preds = %60
%62 = load i32, i32* %11
%63 = add nsw i32 %62, 1
store i32 %63, i32* %11
br label %27
64: ; preds = %27
ret void
}

LLVM IR (-O2):
define void @decode(i32 %0, i8* nocapture %1, float* %2, float* %3, i32 %4) {
%6 = icmp sgt i32 %4, 0
br i1 %6, label %7, label %13
7: ; preds = %5
%8 = shl nuw i32 %4, 1
%9 = bitcast float* %3 to i8*
%10 = call i32 @llvm.smax.i32(i32 %8, i32 1)
%11 = zext i32 %10 to i64
%12 = shl nuw nsw i64 %11, 2
br label %13
13: ; preds = %7, %5
%14 = icmp sgt i32 %0, 0
br i1 %14, label %15, label %31
15: ; preds = %13
%16 = zext i32 %0 to i64
br label %17
17: ; preds = %15, %28
%18 = phi i64 [ 0, %15 ], [ %29, %28 ]
%19 = getelementptr inbounds i8, i8* %1, i64 %18
%20 = load i8, i8* %19
%21 = icmp eq i8 %20, 43
%22 = shl nuw nsw i64 %18, 1
%23 = getelementptr inbounds float, float* %2, i64 %22
br i1 %21, label %24, label %26
24: ; preds = %17
%25 = tail call i32 @cvadd(float* %3, float* %23, float* %3, i32 %4)
br label %28
26: ; preds = %17
%27 = tail call i32 @cvsub(float* %3, float* %23, float* %3, i32 %4)
br label %28
28: ; preds = %24, %26
%29 = add nuw nsw i64 %18, 1
%30 = icmp eq i64 %29, %16
br i1 %30, label %31, label %17
31: ; preds = %28, %13
ret void
}