#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 _ada_use_c2phc(int, int *, int *, double *);
int diagonal_symbols_doubler(int n, int d, int nc, char *s) {
  int k, fail = 0;
  int a[3];
  int b[nc];
  double *c;
  a[0] = n;
  a[1] = d;
  a[2] = nc;
  for (k = 0; k < nc; k++)
    b[k] = (int)s[k];
  fail = _ada_use_c2phc(230, a, b, c);
  return fail;
}


x86 assembly (clang, -O0):
<diagonal_symbols_doubler>:
push   %rbp
mov    %rsp,%rbp
sub    $0x50,%rsp
mov    %edi,-0x4(%rbp)
mov    %esi,-0x8(%rbp)
mov    %edx,-0xc(%rbp)
mov    %rcx,-0x18(%rbp)
movl   $0x0,-0x20(%rbp)
mov    -0xc(%rbp),%eax
mov    %rsp,%rcx
mov    %rcx,-0x38(%rbp)
lea    0xf(,%rax,4),%rdx
and    $0xfffffffffffffff0,%rdx
mov    %rsp,%rcx
sub    %rdx,%rcx
mov    %rcx,-0x50(%rbp)
mov    %rcx,%rsp
mov    %rax,-0x40(%rbp)
mov    -0x4(%rbp),%eax
mov    %eax,-0x2c(%rbp)
mov    -0x8(%rbp),%eax
mov    %eax,-0x28(%rbp)
mov    -0xc(%rbp),%eax
mov    %eax,-0x24(%rbp)
movl   $0x0,-0x1c(%rbp)
mov    -0x1c(%rbp),%eax
cmp    -0xc(%rbp),%eax
jge    119d <diagonal_symbols_doubler+0x8d>
mov    -0x50(%rbp),%rax
mov    -0x18(%rbp),%rcx
movslq -0x1c(%rbp),%rdx
movsbl (%rcx,%rdx,1),%edx
movslq -0x1c(%rbp),%rcx
mov    %edx,(%rax,%rcx,4)
mov    -0x1c(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x1c(%rbp)
jmp    116c <diagonal_symbols_doubler+0x5c>
mov    -0x50(%rbp),%rdx
lea    -0x2c(%rbp),%rsi
mov    -0x48(%rbp),%rcx
mov    $0xe6,%edi
call   1030 <_ada_use_c2phc@plt>
mov    %eax,-0x20(%rbp)
mov    -0x20(%rbp),%eax
mov    -0x38(%rbp),%rcx
mov    %rcx,%rsp
mov    %rbp,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<diagonal_symbols_doubler>:
push   %rbp
mov    %rsp,%rbp
push   %r14
push   %rbx
sub    $0x10,%rsp
mov    %edx,%r8d
mov    %rsp,%r14
mov    %edx,%ebx
mov    %rsp,%rdx
lea    0xf(,%rbx,4),%rax
and    $0xfffffffffffffff0,%rax
sub    %rax,%rdx
mov    %rdx,%rsp
mov    %edi,-0x1c(%rbp)
mov    %esi,-0x18(%rbp)
mov    %r8d,-0x14(%rbp)
test   %r8d,%r8d
jle    1240 <diagonal_symbols_doubler+0x130>
cmp    $0x8,%r8d
jae    1158 <diagonal_symbols_doubler+0x48>
xor    %eax,%eax
jmp    1230 <diagonal_symbols_doubler+0x120>
mov    %ebx,%eax
and    $0xfffffff8,%eax
lea    -0x8(%rax),%rsi
mov    %rsi,%r8
shr    $0x3,%r8
add    $0x1,%r8
test   %rsi,%rsi
je     125a <diagonal_symbols_doubler+0x14a>
mov    %r8,%rdi
and    $0xfffffffffffffffe,%rdi
xor    %esi,%esi
xchg   %ax,%ax
movd   (%rcx,%rsi,1),%xmm0
punpcklbw %xmm0,%xmm0
punpcklwd %xmm0,%xmm0
movd   0x4(%rcx,%rsi,1),%xmm1
punpcklbw %xmm1,%xmm1
punpcklwd %xmm1,%xmm1
psrad  $0x18,%xmm0
psrad  $0x18,%xmm1
movdqa %xmm0,(%rdx,%rsi,4)
movdqa %xmm1,0x10(%rdx,%rsi,4)
movd   0x8(%rcx,%rsi,1),%xmm0
punpcklbw %xmm0,%xmm0
punpcklwd %xmm0,%xmm0
movd   0xc(%rcx,%rsi,1),%xmm1
punpcklbw %xmm1,%xmm1
punpcklwd %xmm1,%xmm1
psrad  $0x18,%xmm0
psrad  $0x18,%xmm1
movdqa %xmm0,0x20(%rdx,%rsi,4)
movdqa %xmm1,0x30(%rdx,%rsi,4)
add    $0x10,%rsi
add    $0xfffffffffffffffe,%rdi
jne    1180 <diagonal_symbols_doubler+0x70>
test   $0x1,%r8b
je     1222 <diagonal_symbols_doubler+0x112>
movd   (%rcx,%rsi,1),%xmm0
movd   0x4(%rcx,%rsi,1),%xmm1
punpcklbw %xmm0,%xmm0
punpcklwd %xmm0,%xmm0
psrad  $0x18,%xmm0
punpcklbw %xmm1,%xmm1
punpcklwd %xmm1,%xmm1
psrad  $0x18,%xmm1
movdqa %xmm0,(%rdx,%rsi,4)
movdqa %xmm1,0x10(%rdx,%rsi,4)
cmp    %rbx,%rax
je     1240 <diagonal_symbols_doubler+0x130>
nopw   0x0(%rax,%rax,1)
movsbl (%rcx,%rax,1),%esi
mov    %esi,(%rdx,%rax,4)
add    $0x1,%rax
cmp    %rax,%rbx
jne    1230 <diagonal_symbols_doubler+0x120>
lea    -0x1c(%rbp),%rsi
mov    $0xe6,%edi
call   1030 <_ada_use_c2phc@plt>
mov    %r14,%rsp
lea    -0x10(%rbp),%rsp
pop    %rbx
pop    %r14
pop    %rbp
ret
xor    %esi,%esi
test   $0x1,%r8b
jne    11f2 <diagonal_symbols_doubler+0xe2>
jmp    1222 <diagonal_symbols_doubler+0x112>

LLVM IR (-O0):
define i32 @diagonal_symbols_doubler(i32 %0, i32 %1, i32 %2, i8* %3) {
%5 = alloca i32
%6 = alloca i32
%7 = alloca i32
%8 = alloca i8*
%9 = alloca i32
%10 = alloca i32
%11 = alloca [3 x i32]
%12 = alloca i8*
%13 = alloca i64
%14 = alloca double*
store i32 %0, i32* %5
store i32 %1, i32* %6
store i32 %2, i32* %7
store i8* %3, i8** %8
store i32 0, i32* %10
%15 = load i32, i32* %7
%16 = zext i32 %15 to i64
%17 = call i8* @llvm.stacksave()
store i8* %17, i8** %12
%18 = alloca i32, i64 %16
store i64 %16, i64* %13
%19 = load i32, i32* %5
%20 = getelementptr inbounds [3 x i32], [3 x i32]* %11, i64 0, i64 0
store i32 %19, i32* %20
%21 = load i32, i32* %6
%22 = getelementptr inbounds [3 x i32], [3 x i32]* %11, i64 0, i64 1
store i32 %21, i32* %22
%23 = load i32, i32* %7
%24 = getelementptr inbounds [3 x i32], [3 x i32]* %11, i64 0, i64 2
store i32 %23, i32* %24
store i32 0, i32* %9
br label %25
25: ; preds = %39, %4
%26 = load i32, i32* %9
%27 = load i32, i32* %7
%28 = icmp slt i32 %26, %27
br i1 %28, label %29, label %42
29: ; preds = %25
%30 = load i8*, i8** %8
%31 = load i32, i32* %9
%32 = sext i32 %31 to i64
%33 = getelementptr inbounds i8, i8* %30, i64 %32
%34 = load i8, i8* %33
%35 = sext i8 %34 to i32
%36 = load i32, i32* %9
%37 = sext i32 %36 to i64
%38 = getelementptr inbounds i32, i32* %18, i64 %37
store i32 %35, i32* %38
br label %39
39: ; preds = %29
%40 = load i32, i32* %9
%41 = add nsw i32 %40, 1
store i32 %41, i32* %9
br label %25
42: ; preds = %25
%43 = getelementptr inbounds [3 x i32], [3 x i32]* %11, i64 0, i64 0
%44 = load double*, double** %14
%45 = call i32 @_ada_use_c2phc(i32 230, i32* %43, i32* %18, double* %44)
store i32 %45, i32* %10
%46 = load i32, i32* %10
%47 = load i8*, i8** %12
ret i32 %46
}

LLVM IR (-O2):
define i32 @diagonal_symbols_doubler(i32 %0, i32 %1, i32 %2, i8* nocapture %3) {
%5 = alloca [3 x i32]
%6 = bitcast [3 x i32]* %5 to i8*
%7 = zext i32 %2 to i64
%8 = tail call i8* @llvm.stacksave()
%9 = alloca i32, i64 %7
%10 = getelementptr inbounds [3 x i32], [3 x i32]* %5, i64 0, i64 0
store i32 %0, i32* %10
%11 = getelementptr inbounds [3 x i32], [3 x i32]* %5, i64 0, i64 1
store i32 %1, i32* %11
%12 = getelementptr inbounds [3 x i32], [3 x i32]* %5, i64 0, i64 2
store i32 %2, i32* %12
%13 = icmp sgt i32 %2, 0
br i1 %13, label %14, label %84
14: ; preds = %4
%15 = icmp ult i32 %2, 8
br i1 %15, label %74, label %16
16: ; preds = %14
%17 = and i64 %7, 4294967288
%18 = add nsw i64 %17, -8
%19 = lshr exact i64 %18, 3
%20 = add nuw nsw i64 %19, 1
%21 = and i64 %20, 1
%22 = icmp eq i64 %18, 0
br i1 %22, label %56, label %23
23: ; preds = %16
%24 = and i64 %20, 4611686018427387902
br label %25
25: ; preds = %25, %23
%26 = phi i64 [ 0, %23 ], [ %53, %25 ]
%27 = phi i64 [ 0, %23 ], [ %54, %25 ]
%28 = getelementptr inbounds i8, i8* %3, i64 %26
%29 = bitcast i8* %28 to <4 x i8>*
%30 = load <4 x i8>, <4 x i8>* %29
%31 = getelementptr inbounds i8, i8* %28, i64 4
%32 = bitcast i8* %31 to <4 x i8>*
%33 = load <4 x i8>, <4 x i8>* %32
%34 = sext <4 x i8> %30 to <4 x i32>
%35 = sext <4 x i8> %33 to <4 x i32>
%36 = getelementptr inbounds i32, i32* %9, i64 %26
%37 = bitcast i32* %36 to <4 x i32>*
store <4 x i32> %34, <4 x i32>* %37
%38 = getelementptr inbounds i32, i32* %36, i64 4
%39 = bitcast i32* %38 to <4 x i32>*
store <4 x i32> %35, <4 x i32>* %39
%40 = or i64 %26, 8
%41 = getelementptr inbounds i8, i8* %3, i64 %40
%42 = bitcast i8* %41 to <4 x i8>*
%43 = load <4 x i8>, <4 x i8>* %42
%44 = getelementptr inbounds i8, i8* %41, i64 4
%45 = bitcast i8* %44 to <4 x i8>*
%46 = load <4 x i8>, <4 x i8>* %45
%47 = sext <4 x i8> %43 to <4 x i32>
%48 = sext <4 x i8> %46 to <4 x i32>
%49 = getelementptr inbounds i32, i32* %9, i64 %40
%50 = bitcast i32* %49 to <4 x i32>*
store <4 x i32> %47, <4 x i32>* %50
%51 = getelementptr inbounds i32, i32* %49, i64 4
%52 = bitcast i32* %51 to <4 x i32>*
store <4 x i32> %48, <4 x i32>* %52
%53 = add nuw i64 %26, 16
%54 = add i64 %27, 2
%55 = icmp eq i64 %54, %24
br i1 %55, label %56, label %25
56: ; preds = %25, %16
%57 = phi i64 [ 0, %16 ], [ %53, %25 ]
%58 = icmp eq i64 %21, 0
br i1 %58, label %72, label %59
59: ; preds = %56
%60 = getelementptr inbounds i8, i8* %3, i64 %57
%61 = bitcast i8* %60 to <4 x i8>*
%62 = load <4 x i8>, <4 x i8>* %61
%63 = getelementptr inbounds i8, i8* %60, i64 4
%64 = bitcast i8* %63 to <4 x i8>*
%65 = load <4 x i8>, <4 x i8>* %64
%66 = sext <4 x i8> %62 to <4 x i32>
%67 = sext <4 x i8> %65 to <4 x i32>
%68 = getelementptr inbounds i32, i32* %9, i64 %57
%69 = bitcast i32* %68 to <4 x i32>*
store <4 x i32> %66, <4 x i32>* %69
%70 = getelementptr inbounds i32, i32* %68, i64 4
%71 = bitcast i32* %70 to <4 x i32>*
store <4 x i32> %67, <4 x i32>* %71
br label %72
72: ; preds = %56, %59
%73 = icmp eq i64 %17, %7
br i1 %73, label %84, label %74
74: ; preds = %14, %72
%75 = phi i64 [ 0, %14 ], [ %17, %72 ]
br label %76
76: ; preds = %74, %76
%77 = phi i64 [ %82, %76 ], [ %75, %74 ]
%78 = getelementptr inbounds i8, i8* %3, i64 %77
%79 = load i8, i8* %78
%80 = sext i8 %79 to i32
%81 = getelementptr inbounds i32, i32* %9, i64 %77
store i32 %80, i32* %81
%82 = add nuw nsw i64 %77, 1
%83 = icmp eq i64 %82, %7
br i1 %83, label %84, label %76
84: ; preds = %76, %72, %4
%85 = call i32 @_ada_use_c2phc(i32 230, i32* %10, i32* %9, double* undef)
ret i32 %85
}