#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 */
scalar_t__ strncmp(char const *, char *, int);
int /*<<< orphan*/ write_log_comment_disp(char *);
int set_dims(int dim[3], const char *axis_order) {
  if (0 == strncmp(axis_order, "xyz", 3)) {
    dim[0] = 0;
    dim[1] = 1;
    dim[2] = 2;
  } else if (0 == strncmp(axis_order, "xzy", 3)) {
    dim[0] = 0;
    dim[2] = 1;
    dim[1] = 2;
  } else if (0 == strncmp(axis_order, "yxz", 3)) {
    dim[1] = 0;
    dim[0] = 1;
    dim[2] = 2;
  } else if (0 == strncmp(axis_order, "yzx", 3)) {
    dim[1] = 0;
    dim[2] = 1;
    dim[0] = 2;
  } else if (0 == strncmp(axis_order, "zxy", 3)) {
    dim[2] = 0;
    dim[0] = 1;
    dim[1] = 2;
  } else if (0 == strncmp(axis_order, "zyx", 3)) {
    dim[2] = 0;
    dim[1] = 1;
    dim[0] = 2;
  } else {
    write_log_comment_disp("Axis order must be a permutation of xyz.\n");
    return 1;
  }
  return 0;
}


x86 assembly (clang, -O0):
<set_dims>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %rdi,-0x10(%rbp)
mov    %rsi,-0x18(%rbp)
mov    -0x18(%rbp),%rdi
lea    0xec5(%rip),%rsi
mov    $0x3,%edx
call   1030 <strncmp@plt>
mov    %rax,%rcx
xor    %eax,%eax
cmp    %rcx,%rax
jne    1178 <set_dims+0x58>
mov    -0x10(%rbp),%rax
movl   $0x0,(%rax)
mov    -0x10(%rbp),%rax
movl   $0x1,0x4(%rax)
mov    -0x10(%rbp),%rax
movl   $0x2,0x8(%rax)
jmp    1311 <set_dims+0x1f1>
mov    -0x18(%rbp),%rdi
lea    0xe81(%rip),%rsi
mov    $0x3,%edx
call   1030 <strncmp@plt>
mov    %rax,%rcx
xor    %eax,%eax
cmp    %rcx,%rax
jne    11c0 <set_dims+0xa0>
mov    -0x10(%rbp),%rax
movl   $0x0,(%rax)
mov    -0x10(%rbp),%rax
movl   $0x1,0x8(%rax)
mov    -0x10(%rbp),%rax
movl   $0x2,0x4(%rax)
jmp    130c <set_dims+0x1ec>
mov    -0x18(%rbp),%rdi
lea    0xe3d(%rip),%rsi
mov    $0x3,%edx
call   1030 <strncmp@plt>
mov    %rax,%rcx
xor    %eax,%eax
cmp    %rcx,%rax
jne    1208 <set_dims+0xe8>
mov    -0x10(%rbp),%rax
movl   $0x0,0x4(%rax)
mov    -0x10(%rbp),%rax
movl   $0x1,(%rax)
mov    -0x10(%rbp),%rax
movl   $0x2,0x8(%rax)
jmp    1307 <set_dims+0x1e7>
mov    -0x18(%rbp),%rdi
lea    0xdf9(%rip),%rsi
mov    $0x3,%edx
call   1030 <strncmp@plt>
mov    %rax,%rcx
xor    %eax,%eax
cmp    %rcx,%rax
jne    1250 <set_dims+0x130>
mov    -0x10(%rbp),%rax
movl   $0x0,0x4(%rax)
mov    -0x10(%rbp),%rax
movl   $0x1,0x8(%rax)
mov    -0x10(%rbp),%rax
movl   $0x2,(%rax)
jmp    1302 <set_dims+0x1e2>
mov    -0x18(%rbp),%rdi
lea    0xdb5(%rip),%rsi
mov    $0x3,%edx
call   1030 <strncmp@plt>
mov    %rax,%rcx
xor    %eax,%eax
cmp    %rcx,%rax
jne    1298 <set_dims+0x178>
mov    -0x10(%rbp),%rax
movl   $0x0,0x8(%rax)
mov    -0x10(%rbp),%rax
movl   $0x1,(%rax)
mov    -0x10(%rbp),%rax
movl   $0x2,0x4(%rax)
jmp    12fd <set_dims+0x1dd>
mov    -0x18(%rbp),%rdi
lea    0xd71(%rip),%rsi
mov    $0x3,%edx
call   1030 <strncmp@plt>
mov    %rax,%rcx
xor    %eax,%eax
cmp    %rcx,%rax
jne    12e0 <set_dims+0x1c0>
mov    -0x10(%rbp),%rax
movl   $0x0,0x8(%rax)
mov    -0x10(%rbp),%rax
movl   $0x1,0x4(%rax)
mov    -0x10(%rbp),%rax
movl   $0x2,(%rax)
jmp    12f8 <set_dims+0x1d8>
lea    0xd31(%rip),%rdi
call   1040 <write_log_comment_disp@plt>
movl   $0x1,-0x4(%rbp)
jmp    1318 <set_dims+0x1f8>
jmp    12fd <set_dims+0x1dd>
jmp    1302 <set_dims+0x1e2>
jmp    1307 <set_dims+0x1e7>
jmp    130c <set_dims+0x1ec>
jmp    1311 <set_dims+0x1f1>
movl   $0x0,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<set_dims>:
push   %r14
push   %rbx
push   %rax
mov    %rsi,%rbx
mov    %rdi,%r14
lea    0xecf(%rip),%rsi
mov    %rbx,%rdi
mov    $0x3,%edx
call   1030 <strncmp@plt>
test   %rax,%rax
je     11e3 <set_dims+0xc3>
lea    0xeb6(%rip),%rsi
mov    %rbx,%rdi
mov    $0x3,%edx
call   1030 <strncmp@plt>
test   %rax,%rax
je     11f2 <set_dims+0xd2>
lea    0xe9d(%rip),%rsi
mov    %rbx,%rdi
mov    $0x3,%edx
call   1030 <strncmp@plt>
test   %rax,%rax
je     1209 <set_dims+0xe9>
lea    0xe84(%rip),%rsi
mov    %rbx,%rdi
mov    $0x3,%edx
call   1030 <strncmp@plt>
test   %rax,%rax
je     1222 <set_dims+0x102>
lea    0xe6b(%rip),%rsi
mov    %rbx,%rdi
mov    $0x3,%edx
call   1030 <strncmp@plt>
test   %rax,%rax
je     1233 <set_dims+0x113>
lea    0xe56(%rip),%rsi
mov    %rbx,%rdi
mov    $0x3,%edx
call   1030 <strncmp@plt>
test   %rax,%rax
je     1247 <set_dims+0x127>
lea    0xe41(%rip),%rdi
call   1040 <write_log_comment_disp@plt>
mov    $0x1,%eax
jmp    121a <set_dims+0xfa>
movabs $0x100000000,%rax
mov    %rax,(%r14)
jmp    1210 <set_dims+0xf0>
movabs $0x200000000,%rax
mov    %rax,(%r14)
movl   $0x1,0x8(%r14)
jmp    1218 <set_dims+0xf8>
movq   $0x1,(%r14)
movl   $0x2,0x8(%r14)
xor    %eax,%eax
add    $0x8,%rsp
pop    %rbx
pop    %r14
ret
movl   $0x1,0x8(%r14)
movq   $0x2,(%r14)
jmp    1218 <set_dims+0xf8>
movl   $0x0,0x8(%r14)
movabs $0x200000001,%rax
jmp    1259 <set_dims+0x139>
movl   $0x0,0x8(%r14)
movabs $0x100000002,%rax
mov    %rax,(%r14)
jmp    1218 <set_dims+0xf8>

LLVM IR (-O0):
@.str = [4 x i8] c"xyz\00"
@.str.1 = [4 x i8] c"xzy\00"
@.str.2 = [4 x i8] c"yxz\00"
@.str.3 = [4 x i8] c"yzx\00"
@.str.4 = [4 x i8] c"zxy\00"
@.str.5 = [4 x i8] c"zyx\00"
@.str.6 = [42 x i8] c"Axis order must be a permutation of xyz.\0A\00"
define i32 @set_dims(i32* %0, i8* %1) {
%3 = alloca i32
%4 = alloca i32*
%5 = alloca i8*
store i32* %0, i32** %4
store i8* %1, i8** %5
%6 = load i8*, i8** %5
%7 = call i64 @strncmp(i8* %6, i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str, i64 0, i64 0), i32 3)
%8 = icmp eq i64 0, %7
br i1 %8, label %9, label %16
9: ; preds = %2
%10 = load i32*, i32** %4
%11 = getelementptr inbounds i32, i32* %10, i64 0
store i32 0, i32* %11
%12 = load i32*, i32** %4
%13 = getelementptr inbounds i32, i32* %12, i64 1
store i32 1, i32* %13
%14 = load i32*, i32** %4
%15 = getelementptr inbounds i32, i32* %14, i64 2
store i32 2, i32* %15
br label %78
16: ; preds = %2
%17 = load i8*, i8** %5
%18 = call i64 @strncmp(i8* %17, i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.1, i64 0, i64 0), i32 3)
%19 = icmp eq i64 0, %18
br i1 %19, label %20, label %27
20: ; preds = %16
%21 = load i32*, i32** %4
%22 = getelementptr inbounds i32, i32* %21, i64 0
store i32 0, i32* %22
%23 = load i32*, i32** %4
%24 = getelementptr inbounds i32, i32* %23, i64 2
store i32 1, i32* %24
%25 = load i32*, i32** %4
%26 = getelementptr inbounds i32, i32* %25, i64 1
store i32 2, i32* %26
br label %77
27: ; preds = %16
%28 = load i8*, i8** %5
%29 = call i64 @strncmp(i8* %28, i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.2, i64 0, i64 0), i32 3)
%30 = icmp eq i64 0, %29
br i1 %30, label %31, label %38
31: ; preds = %27
%32 = load i32*, i32** %4
%33 = getelementptr inbounds i32, i32* %32, i64 1
store i32 0, i32* %33
%34 = load i32*, i32** %4
%35 = getelementptr inbounds i32, i32* %34, i64 0
store i32 1, i32* %35
%36 = load i32*, i32** %4
%37 = getelementptr inbounds i32, i32* %36, i64 2
store i32 2, i32* %37
br label %76
38: ; preds = %27
%39 = load i8*, i8** %5
%40 = call i64 @strncmp(i8* %39, i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.3, i64 0, i64 0), i32 3)
%41 = icmp eq i64 0, %40
br i1 %41, label %42, label %49
42: ; preds = %38
%43 = load i32*, i32** %4
%44 = getelementptr inbounds i32, i32* %43, i64 1
store i32 0, i32* %44
%45 = load i32*, i32** %4
%46 = getelementptr inbounds i32, i32* %45, i64 2
store i32 1, i32* %46
%47 = load i32*, i32** %4
%48 = getelementptr inbounds i32, i32* %47, i64 0
store i32 2, i32* %48
br label %75
49: ; preds = %38
%50 = load i8*, i8** %5
%51 = call i64 @strncmp(i8* %50, i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.4, i64 0, i64 0), i32 3)
%52 = icmp eq i64 0, %51
br i1 %52, label %53, label %60
53: ; preds = %49
%54 = load i32*, i32** %4
%55 = getelementptr inbounds i32, i32* %54, i64 2
store i32 0, i32* %55
%56 = load i32*, i32** %4
%57 = getelementptr inbounds i32, i32* %56, i64 0
store i32 1, i32* %57
%58 = load i32*, i32** %4
%59 = getelementptr inbounds i32, i32* %58, i64 1
store i32 2, i32* %59
br label %74
60: ; preds = %49
%61 = load i8*, i8** %5
%62 = call i64 @strncmp(i8* %61, i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.5, i64 0, i64 0), i32 3)
%63 = icmp eq i64 0, %62
br i1 %63, label %64, label %71
64: ; preds = %60
%65 = load i32*, i32** %4
%66 = getelementptr inbounds i32, i32* %65, i64 2
store i32 0, i32* %66
%67 = load i32*, i32** %4
%68 = getelementptr inbounds i32, i32* %67, i64 1
store i32 1, i32* %68
%69 = load i32*, i32** %4
%70 = getelementptr inbounds i32, i32* %69, i64 0
store i32 2, i32* %70
br label %73
71: ; preds = %60
%72 = call i32 @write_log_comment_disp(i8* getelementptr inbounds ([42 x i8], [42 x i8]* @.str.6, i64 0, i64 0))
store i32 1, i32* %3
br label %79
73: ; preds = %64
br label %74
74: ; preds = %73, %53
br label %75
75: ; preds = %74, %42
br label %76
76: ; preds = %75, %31
br label %77
77: ; preds = %76, %20
br label %78
78: ; preds = %77, %9
store i32 0, i32* %3
br label %79
79: ; preds = %78, %71
%80 = load i32, i32* %3
ret i32 %80
}

LLVM IR (-O2):
@.str = [4 x i8] c"xyz\00"
@.str.1 = [4 x i8] c"xzy\00"
@.str.2 = [4 x i8] c"yxz\00"
@.str.3 = [4 x i8] c"yzx\00"
@.str.4 = [4 x i8] c"zxy\00"
@.str.5 = [4 x i8] c"zyx\00"
@.str.6 = [42 x i8] c"Axis order must be a permutation of xyz.\0A\00"
define i32 @set_dims(i32* nocapture writeonly %0, i8* %1) {
%3 = tail call i64 @strncmp(i8* %1, i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str, i64 0, i64 0), i32 3)
%4 = icmp eq i64 %3, 0
br i1 %4, label %5, label %8
5: ; preds = %2
store i32 0, i32* %0
%6 = getelementptr inbounds i32, i32* %0, i64 1
store i32 1, i32* %6
%7 = getelementptr inbounds i32, i32* %0, i64 2
store i32 2, i32* %7
br label %40
8: ; preds = %2
%9 = tail call i64 @strncmp(i8* %1, i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.1, i64 0, i64 0), i32 3)
%10 = icmp eq i64 %9, 0
br i1 %10, label %11, label %14
11: ; preds = %8
store i32 0, i32* %0
%12 = getelementptr inbounds i32, i32* %0, i64 2
store i32 1, i32* %12
%13 = getelementptr inbounds i32, i32* %0, i64 1
store i32 2, i32* %13
br label %40
14: ; preds = %8
%15 = tail call i64 @strncmp(i8* %1, i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.2, i64 0, i64 0), i32 3)
%16 = icmp eq i64 %15, 0
br i1 %16, label %17, label %20
17: ; preds = %14
%18 = getelementptr inbounds i32, i32* %0, i64 1
store i32 0, i32* %18
store i32 1, i32* %0
%19 = getelementptr inbounds i32, i32* %0, i64 2
store i32 2, i32* %19
br label %40
20: ; preds = %14
%21 = tail call i64 @strncmp(i8* %1, i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.3, i64 0, i64 0), i32 3)
%22 = icmp eq i64 %21, 0
br i1 %22, label %23, label %26
23: ; preds = %20
%24 = getelementptr inbounds i32, i32* %0, i64 1
store i32 0, i32* %24
%25 = getelementptr inbounds i32, i32* %0, i64 2
store i32 1, i32* %25
store i32 2, i32* %0
br label %40
26: ; preds = %20
%27 = tail call i64 @strncmp(i8* %1, i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.4, i64 0, i64 0), i32 3)
%28 = icmp eq i64 %27, 0
br i1 %28, label %29, label %32
29: ; preds = %26
%30 = getelementptr inbounds i32, i32* %0, i64 2
store i32 0, i32* %30
store i32 1, i32* %0
%31 = getelementptr inbounds i32, i32* %0, i64 1
store i32 2, i32* %31
br label %40
32: ; preds = %26
%33 = tail call i64 @strncmp(i8* %1, i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.5, i64 0, i64 0), i32 3)
%34 = icmp eq i64 %33, 0
br i1 %34, label %35, label %38
35: ; preds = %32
%36 = getelementptr inbounds i32, i32* %0, i64 2
store i32 0, i32* %36
%37 = getelementptr inbounds i32, i32* %0, i64 1
store i32 1, i32* %37
store i32 2, i32* %0
br label %40
38: ; preds = %32
%39 = tail call i32 @write_log_comment_disp(i8* getelementptr inbounds ([42 x i8], [42 x i8]* @.str.6, i64 0, i64 0))
br label %40
40: ; preds = %5, %17, %29, %35, %23, %11, %38
%41 = phi i32 [ 1, %38 ], [ 0, %11 ], [ 0, %23 ], [ 0, %35 ], [ 0, %29 ], [ 0, %17 ], [ 0, %5 ]
ret i32 %41
}