#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*/ memset(char *, int /*<<< orphan*/, int);
char *mjpai_string(int);
int /*<<< orphan*/ strcat(char *, char *);
const char *mj_string(int *pais, int len, int line_number) {
  static char str[256];
  int i, pai_id, n;
  memset(str, 0, 256);
  if (pais && len > 0) {
    n = 0;
    for (i = 0; i < len; i++) {
      pai_id = *(pais + i);
      if (pai_id != 0) {
        strcat(str, mjpai_string(pai_id));
        n++;
        if (n >= line_number) {
          strcat(str, "\n");
          n = 0;
        }
      }
    }
  }
  return str;
}


x86 assembly (clang, -O0):
<mj_string>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %rdi,-0x8(%rbp)
mov    %esi,-0xc(%rbp)
mov    %edx,-0x10(%rbp)
lea    0x2f07(%rip),%rdi
xor    %esi,%esi
mov    $0x100,%edx
call   1030 <memset@plt>
cmpq   $0x0,-0x8(%rbp)
je     11ff <mj_string+0xcf>
cmpl   $0x0,-0xc(%rbp)
jle    11ff <mj_string+0xcf>
movl   $0x0,-0x1c(%rbp)
movl   $0x0,-0x14(%rbp)
mov    -0x14(%rbp),%eax
cmp    -0xc(%rbp),%eax
jge    11fa <mj_string+0xca>
mov    -0x8(%rbp),%rax
movslq -0x14(%rbp),%rcx
mov    (%rax,%rcx,4),%eax
mov    %eax,-0x18(%rbp)
cmpl   $0x0,-0x18(%rbp)
je     11e7 <mj_string+0xb7>
mov    -0x18(%rbp),%edi
call   1050 <mjpai_string@plt>
mov    %rax,%rsi
lea    0x2ea2(%rip),%rdi
call   1040 <strcat@plt>
mov    -0x1c(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x1c(%rbp)
mov    -0x1c(%rbp),%eax
cmp    -0x10(%rbp),%eax
jl     11e2 <mj_string+0xb2>
lea    0x2e81(%rip),%rdi
lea    0xe2a(%rip),%rsi
call   1040 <strcat@plt>
movl   $0x0,-0x1c(%rbp)
jmp    11e7 <mj_string+0xb7>
jmp    11ec <mj_string+0xbc>
mov    -0x14(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x14(%rbp)
jmp    1178 <mj_string+0x48>
jmp    11ff <mj_string+0xcf>
lea    0x2e4a(%rip),%rax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<mj_string>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
push   %rax
mov    %edx,%r12d
mov    %esi,%r14d
mov    %rdi,%r13
lea    0x2f05(%rip),%rdi
xor    %esi,%esi
mov    $0x100,%edx
call   1030 <memset@plt>
test   %r13,%r13
je     11bf <mj_string+0x8f>
test   %r14d,%r14d
jle    11bf <mj_string+0x8f>
mov    %r14d,%ebp
xor    %ebx,%ebx
lea    0x2ee3(%rip),%r14
xor    %r15d,%r15d
jmp    1189 <mj_string+0x59>
cs nopw 0x0(%rax,%rax,1)
nopl   0x0(%rax)
add    $0x1,%rbx
cmp    %rbx,%rbp
je     11bf <mj_string+0x8f>
mov    0x0(%r13,%rbx,4),%edi
test   %edi,%edi
je     1180 <mj_string+0x50>
call   1050 <mjpai_string@plt>
mov    %r14,%rdi
mov    %rax,%rsi
call   1040 <strcat@plt>
add    $0x1,%r15d
cmp    %r12d,%r15d
jl     1180 <mj_string+0x50>
mov    %r14,%rdi
lea    0xe4b(%rip),%rsi
call   1040 <strcat@plt>
xor    %r15d,%r15d
jmp    1180 <mj_string+0x50>
lea    0x2e8a(%rip),%rax
add    $0x8,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
@mj_string.str = internal global [256 x i8] zeroinitializer
@.str = [2 x i8] c"\0A\00"
define i8* @mj_string(i32* %0, i32 %1, i32 %2) {
%4 = alloca i32*
%5 = alloca i32
%6 = alloca i32
%7 = alloca i32
%8 = alloca i32
%9 = alloca i32
store i32* %0, i32** %4
store i32 %1, i32* %5
store i32 %2, i32* %6
%10 = call i32 @memset(i8* getelementptr inbounds ([256 x i8], [256 x i8]* @mj_string.str, i64 0, i64 0), i32 0, i32 256)
%11 = load i32*, i32** %4
%12 = icmp ne i32* %11, null
br i1 %12, label %13, label %46
13: ; preds = %3
%14 = load i32, i32* %5
%15 = icmp sgt i32 %14, 0
br i1 %15, label %16, label %46
16: ; preds = %13
store i32 0, i32* %9
store i32 0, i32* %7
br label %17
17: ; preds = %42, %16
%18 = load i32, i32* %7
%19 = load i32, i32* %5
%20 = icmp slt i32 %18, %19
br i1 %20, label %21, label %45
21: ; preds = %17
%22 = load i32*, i32** %4
%23 = load i32, i32* %7
%24 = sext i32 %23 to i64
%25 = getelementptr inbounds i32, i32* %22, i64 %24
%26 = load i32, i32* %25
store i32 %26, i32* %8
%27 = load i32, i32* %8
%28 = icmp ne i32 %27, 0
br i1 %28, label %29, label %41
29: ; preds = %21
%30 = load i32, i32* %8
%31 = call i8* @mjpai_string(i32 %30)
%32 = call i32 @strcat(i8* getelementptr inbounds ([256 x i8], [256 x i8]* @mj_string.str, i64 0, i64 0), i8* %31)
%33 = load i32, i32* %9
%34 = add nsw i32 %33, 1
store i32 %34, i32* %9
%35 = load i32, i32* %9
%36 = load i32, i32* %6
%37 = icmp sge i32 %35, %36
br i1 %37, label %38, label %40
38: ; preds = %29
%39 = call i32 @strcat(i8* getelementptr inbounds ([256 x i8], [256 x i8]* @mj_string.str, i64 0, i64 0), i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str, i64 0, i64 0))
store i32 0, i32* %9
br label %40
40: ; preds = %38, %29
br label %41
41: ; preds = %40, %21
br label %42
42: ; preds = %41
%43 = load i32, i32* %7
%44 = add nsw i32 %43, 1
store i32 %44, i32* %7
br label %17
45: ; preds = %17
br label %46
46: ; preds = %45, %13, %3
ret i8* getelementptr inbounds ([256 x i8], [256 x i8]* @mj_string.str, i64 0, i64 0)
}

LLVM IR (-O2):
@mj_string.str = internal global [256 x i8] zeroinitializer
@.str = [2 x i8] c"\0A\00"
define i8* @mj_string(i32* %0, i32 %1, i32 %2) {
%4 = tail call i32 @memset(i8* getelementptr inbounds ([256 x i8], [256 x i8]* @mj_string.str, i64 0, i64 0), i32 0, i32 256)
%5 = icmp ne i32* %0, null
%6 = icmp sgt i32 %1, 0
%7 = and i1 %5, %6
br i1 %7, label %8, label %27
8: ; preds = %3
%9 = zext i32 %1 to i64
br label %10
10: ; preds = %8, %23
%11 = phi i64 [ 0, %8 ], [ %25, %23 ]
%12 = phi i32 [ 0, %8 ], [ %24, %23 ]
%13 = getelementptr inbounds i32, i32* %0, i64 %11
%14 = load i32, i32* %13
%15 = icmp eq i32 %14, 0
br i1 %15, label %23, label %16
16: ; preds = %10
%17 = tail call i8* @mjpai_string(i32 %14)
%18 = tail call i32 @strcat(i8* getelementptr inbounds ([256 x i8], [256 x i8]* @mj_string.str, i64 0, i64 0), i8* %17)
%19 = add nsw i32 %12, 1
%20 = icmp slt i32 %19, %2
br i1 %20, label %23, label %21
21: ; preds = %16
%22 = tail call i32 @strcat(i8* getelementptr inbounds ([256 x i8], [256 x i8]* @mj_string.str, i64 0, i64 0), i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str, i64 0, i64 0))
br label %23
23: ; preds = %10, %21, %16
%24 = phi i32 [ 0, %21 ], [ %19, %16 ], [ %12, %10 ]
%25 = add nuw nsw i64 %11, 1
%26 = icmp eq i64 %25, %9
br i1 %26, label %27, label %10
27: ; preds = %23, %3
ret i8* getelementptr inbounds ([256 x i8], [256 x i8]* @mj_string.str, i64 0, i64 0)
}