#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 */
typedef size_t uint;

/* Variables and functions */
size_t xencode_char(char const);
void xstr_to_pseq(uint n, uint ndim, const char *str, double **p) {
  uint i, j;
  for (i = 0; i < n; i++) {
    for (j = 0; j < ndim; j++)
      p[i][j] = 0;
    p[i][xencode_char(str[i])] = 1;
  }
}


x86 assembly (clang, -O0):
<xstr_to_pseq>:
push   %rbp
mov    %rsp,%rbp
sub    $0x40,%rsp
mov    %rdi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
mov    %rdx,-0x18(%rbp)
mov    %rcx,-0x20(%rbp)
movq   $0x0,-0x28(%rbp)
mov    -0x28(%rbp),%rax
cmp    -0x8(%rbp),%rax
jae    11c3 <xstr_to_pseq+0xb3>
movq   $0x0,-0x30(%rbp)
mov    -0x30(%rbp),%rax
cmp    -0x10(%rbp),%rax
jae    117d <xstr_to_pseq+0x6d>
mov    -0x20(%rbp),%rax
mov    -0x28(%rbp),%rcx
mov    (%rax,%rcx,8),%rax
mov    -0x30(%rbp),%rcx
xorps  %xmm0,%xmm0
movsd  %xmm0,(%rax,%rcx,8)
mov    -0x30(%rbp),%rax
add    $0x1,%rax
mov    %rax,-0x30(%rbp)
jmp    1146 <xstr_to_pseq+0x36>
mov    -0x20(%rbp),%rax
mov    -0x28(%rbp),%rcx
mov    (%rax,%rcx,8),%rax
mov    %rax,-0x38(%rbp)
mov    -0x18(%rbp),%rax
mov    -0x28(%rbp),%rcx
movsbl (%rax,%rcx,1),%edi
call   1030 <xencode_char@plt>
mov    %rax,%rcx
mov    -0x38(%rbp),%rax
movsd  0xe53(%rip),%xmm0
movsd  %xmm0,(%rax,%rcx,8)
mov    -0x28(%rbp),%rax
add    $0x1,%rax
mov    %rax,-0x28(%rbp)
jmp    1130 <xstr_to_pseq+0x20>
add    $0x40,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<xstr_to_pseq>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
push   %rax
test   %rdi,%rdi
je     118b <xstr_to_pseq+0x6b>
mov    %rcx,%r14
mov    %rdx,%r15
mov    %rsi,%r12
mov    %rdi,%rbx
lea    0x0(,%rsi,8),%rax
mov    %rax,(%rsp)
xor    %r13d,%r13d
jmp    1172 <xstr_to_pseq+0x52>
nopl   (%rax)
movsbl (%r15,%r13,1),%edi
call   1040 <xencode_char@plt>
movabs $0x3ff0000000000000,%rcx
mov    %rcx,0x0(%rbp,%rax,8)
add    $0x1,%r13
cmp    %r13,%rbx
je     118b <xstr_to_pseq+0x6b>
mov    (%r14,%r13,8),%rbp
test   %r12,%r12
je     1150 <xstr_to_pseq+0x30>
mov    %rbp,%rdi
xor    %esi,%esi
mov    (%rsp),%rdx
call   1030 <memset@plt>
jmp    1150 <xstr_to_pseq+0x30>
add    $0x8,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
define void @xstr_to_pseq(i64 %0, i64 %1, i8* %2, double** %3) {
%5 = alloca i64
%6 = alloca i64
%7 = alloca i8*
%8 = alloca double**
%9 = alloca i64
%10 = alloca i64
store i64 %0, i64* %5
store i64 %1, i64* %6
store i8* %2, i8** %7
store double** %3, double*** %8
store i64 0, i64* %9
br label %11
11: ; preds = %41, %4
%12 = load i64, i64* %9
%13 = load i64, i64* %5
%14 = icmp ult i64 %12, %13
br i1 %14, label %15, label %44
15: ; preds = %11
store i64 0, i64* %10
br label %16
16: ; preds = %27, %15
%17 = load i64, i64* %10
%18 = load i64, i64* %6
%19 = icmp ult i64 %17, %18
br i1 %19, label %20, label %30
20: ; preds = %16
%21 = load double**, double*** %8
%22 = load i64, i64* %9
%23 = getelementptr inbounds double*, double** %21, i64 %22
%24 = load double*, double** %23
%25 = load i64, i64* %10
%26 = getelementptr inbounds double, double* %24, i64 %25
store double 0.000000e+00, double* %26
br label %27
27: ; preds = %20
%28 = load i64, i64* %10
%29 = add i64 %28, 1
store i64 %29, i64* %10
br label %16
30: ; preds = %16
%31 = load double**, double*** %8
%32 = load i64, i64* %9
%33 = getelementptr inbounds double*, double** %31, i64 %32
%34 = load double*, double** %33
%35 = load i8*, i8** %7
%36 = load i64, i64* %9
%37 = getelementptr inbounds i8, i8* %35, i64 %36
%38 = load i8, i8* %37
%39 = call i64 @xencode_char(i8 signext %38)
%40 = getelementptr inbounds double, double* %34, i64 %39
store double 1.000000e+00, double* %40
br label %41
41: ; preds = %30
%42 = load i64, i64* %9
%43 = add i64 %42, 1
store i64 %43, i64* %9
br label %11
44: ; preds = %11
ret void
}

LLVM IR (-O2):
define void @xstr_to_pseq(i64 %0, i64 %1, i8* nocapture %2, double** nocapture %3) {
%5 = icmp eq i64 %0, 0
br i1 %5, label %22, label %6
6: ; preds = %4
%7 = icmp eq i64 %1, 0
%8 = shl nuw i64 %1, 3
br label %9
9: ; preds = %6, %15
%10 = phi i64 [ 0, %6 ], [ %20, %15 ]
%11 = getelementptr inbounds double*, double** %3, i64 %10
%12 = load double*, double** %11
br i1 %7, label %15, label %13
13: ; preds = %9
%14 = bitcast double* %12 to i8*
br label %15
15: ; preds = %9, %13
%16 = getelementptr inbounds i8, i8* %2, i64 %10
%17 = load i8, i8* %16
%18 = tail call i64 @xencode_char(i8 signext %17)
%19 = getelementptr inbounds double, double* %12, i64 %18
store double 1.000000e+00, double* %19
%20 = add nuw i64 %10, 1
%21 = icmp eq i64 %20, %0
br i1 %21, label %22, label %9
22: ; preds = %15, %4
ret void
}