#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*/ strncpy(char *, char *, int);
int Get_grid_type(void *self, int grid, char *type) {
  int status = (0);
  if (grid == 0) {
    strncpy(type, "uniform_rectilinear", (2048));
  } else if (grid == 1) {
    strncpy(type, "scalar", (2048));
  } else {
    type[0] = '\0';
    status = (1);
  }
  return status;
}


x86 assembly (clang, -O0):
<Get_grid_type>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %rdi,-0x8(%rbp)
mov    %esi,-0xc(%rbp)
mov    %rdx,-0x18(%rbp)
movl   $0x0,-0x1c(%rbp)
cmpl   $0x0,-0xc(%rbp)
jne    114e <Get_grid_type+0x3e>
mov    -0x18(%rbp),%rdi
lea    0xec1(%rip),%rsi
mov    $0x800,%edx
call   1030 <strncpy@plt>
jmp    1185 <Get_grid_type+0x75>
cmpl   $0x1,-0xc(%rbp)
jne    1172 <Get_grid_type+0x62>
mov    -0x18(%rbp),%rdi
lea    0xeb1(%rip),%rsi
mov    $0x800,%edx
call   1030 <strncpy@plt>
jmp    1180 <Get_grid_type+0x70>
mov    -0x18(%rbp),%rax
movb   $0x0,(%rax)
movl   $0x1,-0x1c(%rbp)
jmp    1185 <Get_grid_type+0x75>
mov    -0x1c(%rbp),%eax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<Get_grid_type>:
push   %rax
cmp    $0x1,%esi
je     1123 <Get_grid_type+0x13>
test   %esi,%esi
jne    113b <Get_grid_type+0x2b>
lea    0xedf(%rip),%rsi
jmp    112a <Get_grid_type+0x1a>
lea    0xeea(%rip),%rsi
mov    %rdx,%rdi
mov    $0x800,%edx
call   1030 <strncpy@plt>
xor    %eax,%eax
pop    %rcx
ret
movb   $0x0,(%rdx)
mov    $0x1,%eax
pop    %rcx
ret

LLVM IR (-O0):
@.str = [20 x i8] c"uniform_rectilinear\00"
@.str.1 = [7 x i8] c"scalar\00"
define i32 @Get_grid_type(i8* %0, i32 %1, i8* %2) {
%4 = alloca i8*
%5 = alloca i32
%6 = alloca i8*
%7 = alloca i32
store i8* %0, i8** %4
store i32 %1, i32* %5
store i8* %2, i8** %6
store i32 0, i32* %7
%8 = load i32, i32* %5
%9 = icmp eq i32 %8, 0
br i1 %9, label %10, label %13
10: ; preds = %3
%11 = load i8*, i8** %6
%12 = call i32 @strncpy(i8* %11, i8* getelementptr inbounds ([20 x i8], [20 x i8]* @.str, i64 0, i64 0), i32 2048)
br label %23
13: ; preds = %3
%14 = load i32, i32* %5
%15 = icmp eq i32 %14, 1
br i1 %15, label %16, label %19
16: ; preds = %13
%17 = load i8*, i8** %6
%18 = call i32 @strncpy(i8* %17, i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str.1, i64 0, i64 0), i32 2048)
br label %22
19: ; preds = %13
%20 = load i8*, i8** %6
%21 = getelementptr inbounds i8, i8* %20, i64 0
store i8 0, i8* %21
store i32 1, i32* %7
br label %22
22: ; preds = %19, %16
br label %23
23: ; preds = %22, %10
%24 = load i32, i32* %7
ret i32 %24
}

LLVM IR (-O2):
@.str = [20 x i8] c"uniform_rectilinear\00"
@.str.1 = [7 x i8] c"scalar\00"
define i32 @Get_grid_type(i8* nocapture readnone %0, i32 %1, i8* %2) {
switch i32 %1, label %8 [
i32 0, label %4
i32 1, label %6
]
4: ; preds = %3
%5 = tail call i32 @strncpy(i8* %2, i8* getelementptr inbounds ([20 x i8], [20 x i8]* @.str, i64 0, i64 0), i32 2048)
br label %9
6: ; preds = %3
%7 = tail call i32 @strncpy(i8* %2, i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str.1, i64 0, i64 0), i32 2048)
br label %9
8: ; preds = %3
store i8 0, i8* %2
br label %9
9: ; preds = %6, %8, %4
%10 = phi i32 [ 0, %4 ], [ 0, %6 ], [ 1, %8 ]
ret i32 %10
}