#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 flag_table_3_3(unsigned char **);
int /*<<< orphan*/ sprintf(char *, char *);
int /*<<< orphan*/ strlen(char *);
int f_vector_dir(int mode, unsigned char **sec, float *data, unsigned int ndata,
                 char *inv_out, void **local) {
  int res;
  if (mode >= 0) {
    res = flag_table_3_3(sec);
    if (res >= 0) {
      sprintf(inv_out, res & 8 ? "winds(grid)" : "winds(N/S)");
      inv_out += strlen(inv_out);
    }
  }
  return 0;
}


x86 assembly (clang, -O0):
<f_vector_dir>:
push   %rbp
mov    %rsp,%rbp
sub    $0x40,%rsp
mov    %edi,-0x4(%rbp)
mov    %rsi,-0x10(%rbp)
mov    %rdx,-0x18(%rbp)
mov    %ecx,-0x1c(%rbp)
mov    %r8,-0x28(%rbp)
mov    %r9,-0x30(%rbp)
cmpl   $0x0,-0x4(%rbp)
jl     11b0 <f_vector_dir+0x80>
mov    -0x10(%rbp),%rdi
call   1050 <flag_table_3_3@plt>
mov    %eax,-0x34(%rbp)
cmpl   $0x0,-0x34(%rbp)
jl     11ab <f_vector_dir+0x7b>
mov    -0x28(%rbp),%rdi
mov    -0x34(%rbp),%ecx
and    $0x8,%ecx
lea    0xe8d(%rip),%rsi
lea    0xe7a(%rip),%rax
cmp    $0x0,%ecx
cmovne %rax,%rsi
call   1040 <sprintf@plt>
mov    -0x28(%rbp),%rdi
call   1030 <strlen@plt>
mov    %eax,%ecx
mov    -0x28(%rbp),%rax
movslq %ecx,%rcx
add    %rcx,%rax
mov    %rax,-0x28(%rbp)
jmp    11b0 <f_vector_dir+0x80>
xor    %eax,%eax
add    $0x40,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<f_vector_dir>:
push   %rbx
test   %edi,%edi
js     1168 <f_vector_dir+0x38>
mov    %r8,%rbx
mov    %rsi,%rdi
call   1050 <flag_table_3_3@plt>
test   %eax,%eax
js     1168 <f_vector_dir+0x38>
test   $0x8,%al
lea    0xebf(%rip),%rax
lea    0xeac(%rip),%rsi
cmove  %rax,%rsi
mov    %rbx,%rdi
call   1040 <sprintf@plt>
mov    %rbx,%rdi
call   1030 <strlen@plt>
xor    %eax,%eax
pop    %rbx
ret

LLVM IR (-O0):
@.str = [12 x i8] c"winds(grid)\00"
@.str.1 = [11 x i8] c"winds(N/S)\00"
define i32 @f_vector_dir(i32 %0, i8** %1, float* %2, i32 %3, i8* %4, i8** %5) {
%7 = alloca i32
%8 = alloca i8**
%9 = alloca float*
%10 = alloca i32
%11 = alloca i8*
%12 = alloca i8**
%13 = alloca i32
store i32 %0, i32* %7
store i8** %1, i8*** %8
store float* %2, float** %9
store i32 %3, i32* %10
store i8* %4, i8** %11
store i8** %5, i8*** %12
%14 = load i32, i32* %7
%15 = icmp sge i32 %14, 0
br i1 %15, label %16, label %35
16: ; preds = %6
%17 = load i8**, i8*** %8
%18 = call i32 @flag_table_3_3(i8** %17)
store i32 %18, i32* %13
%19 = load i32, i32* %13
%20 = icmp sge i32 %19, 0
br i1 %20, label %21, label %34
21: ; preds = %16
%22 = load i8*, i8** %11
%23 = load i32, i32* %13
%24 = and i32 %23, 8
%25 = icmp ne i32 %24, 0
%26 = zext i1 %25 to i64
%27 = select i1 %25, i8* getelementptr inbounds ([12 x i8], [12 x i8]* @.str, i64 0, i64 0), i8* getelementptr inbounds ([11 x i8], [11 x i8]* @.str.1, i64 0, i64 0)
%28 = call i32 @sprintf(i8* %22, i8* %27)
%29 = load i8*, i8** %11
%30 = call i32 @strlen(i8* %29)
%31 = load i8*, i8** %11
%32 = sext i32 %30 to i64
%33 = getelementptr inbounds i8, i8* %31, i64 %32
store i8* %33, i8** %11
br label %34
34: ; preds = %21, %16
br label %35
35: ; preds = %34, %6
ret i32 0
}

LLVM IR (-O2):
@.str = [12 x i8] c"winds(grid)\00"
@.str.1 = [11 x i8] c"winds(N/S)\00"
define i32 @f_vector_dir(i32 %0, i8** %1, float* nocapture readnone %2, i32 %3, i8* %4, i8** nocapture readnone %5) {
%7 = icmp sgt i32 %0, -1
br i1 %7, label %8, label %17
8: ; preds = %6
%9 = tail call i32 @flag_table_3_3(i8** %1)
%10 = icmp sgt i32 %9, -1
br i1 %10, label %11, label %17
11: ; preds = %8
%12 = and i32 %9, 8
%13 = icmp eq i32 %12, 0
%14 = select i1 %13, i8* getelementptr inbounds ([11 x i8], [11 x i8]* @.str.1, i64 0, i64 0), i8* getelementptr inbounds ([12 x i8], [12 x i8]* @.str, i64 0, i64 0)
%15 = tail call i32 @sprintf(i8* dereferenceable(1) %4, i8* dereferenceable(1) %14)
%16 = tail call i32 @strlen(i8* %4)
br label %17
17: ; preds = %8, %11, %6
ret i32 0
}