#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 */
typedef struct TYPE_3__ TYPE_1__;

/* Type definitions */
typedef scalar_t__ ns_sect;
struct TYPE_3__ {
  int _rrnum;
  int /*<<< orphan*/ **_sections;
  int /*<<< orphan*/ *_msg_ptr;
  scalar_t__ _sect;
};
typedef TYPE_1__ ns_msg;

/* Variables and functions */
scalar_t__ ns_s_max;
void local_ns_setsection(ns_msg *msg, ns_sect sect) {
  msg->_sect = sect;
  if (sect == ns_s_max) {
    msg->_rrnum = -1;
    msg->_msg_ptr = NULL;
  } else {
    msg->_rrnum = 0;
    msg->_msg_ptr = msg->_sections[(int)sect];
  }
}


x86 assembly (clang, -O0):
<local_ns_setsection>:
push   %rbp
mov    %rsp,%rbp
mov    %rdi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
mov    -0x10(%rbp),%rcx
mov    -0x8(%rbp),%rax
mov    %rcx,0x18(%rax)
mov    -0x10(%rbp),%rax
mov    0x2eb5(%rip),%rcx
cmp    (%rcx),%rax
jne    1147 <local_ns_setsection+0x47>
mov    -0x8(%rbp),%rax
movl   $0xffffffff,(%rax)
mov    -0x8(%rbp),%rax
movq   $0x0,0x10(%rax)
jmp    116c <local_ns_setsection+0x6c>
mov    -0x8(%rbp),%rax
movl   $0x0,(%rax)
mov    -0x8(%rbp),%rax
mov    0x8(%rax),%rax
mov    -0x10(%rbp),%rcx
movslq %ecx,%rcx
mov    (%rax,%rcx,8),%rcx
mov    -0x8(%rbp),%rax
mov    %rcx,0x10(%rax)
pop    %rbp
ret

x86 assembly (clang, -O2):
<local_ns_setsection>:
mov    %rsi,0x18(%rdi)
mov    0x2ecd(%rip),%rcx
xor    %eax,%eax
cmp    %rsi,(%rcx)
jne    1119 <local_ns_setsection+0x19>
mov    $0xffffffff,%ecx
jmp    1126 <local_ns_setsection+0x26>
mov    0x8(%rdi),%rax
movslq %esi,%rcx
mov    (%rax,%rcx,8),%rax
xor    %ecx,%ecx
mov    %ecx,(%rdi)
mov    %rax,0x10(%rdi)
ret

LLVM IR (-O0):
%struct.TYPE_3__ = type { i32, i32**, i32*, i64 }
@ns_s_max = global i64 0
define void @local_ns_setsection(%struct.TYPE_3__* %0, i64 %1) {
%3 = alloca %struct.TYPE_3__*
%4 = alloca i64
store %struct.TYPE_3__* %0, %struct.TYPE_3__** %3
store i64 %1, i64* %4
%5 = load i64, i64* %4
%6 = load %struct.TYPE_3__*, %struct.TYPE_3__** %3
%7 = getelementptr inbounds %struct.TYPE_3__, %struct.TYPE_3__* %6, i32 0, i32 3
store i64 %5, i64* %7
%8 = load i64, i64* %4
%9 = load i64, i64* @ns_s_max
%10 = icmp eq i64 %8, %9
br i1 %10, label %11, label %16
11: ; preds = %2
%12 = load %struct.TYPE_3__*, %struct.TYPE_3__** %3
%13 = getelementptr inbounds %struct.TYPE_3__, %struct.TYPE_3__* %12, i32 0, i32 0
store i32 -1, i32* %13
%14 = load %struct.TYPE_3__*, %struct.TYPE_3__** %3
%15 = getelementptr inbounds %struct.TYPE_3__, %struct.TYPE_3__* %14, i32 0, i32 2
store i32* null, i32** %15
br label %29
16: ; preds = %2
%17 = load %struct.TYPE_3__*, %struct.TYPE_3__** %3
%18 = getelementptr inbounds %struct.TYPE_3__, %struct.TYPE_3__* %17, i32 0, i32 0
store i32 0, i32* %18
%19 = load %struct.TYPE_3__*, %struct.TYPE_3__** %3
%20 = getelementptr inbounds %struct.TYPE_3__, %struct.TYPE_3__* %19, i32 0, i32 1
%21 = load i32**, i32*** %20
%22 = load i64, i64* %4
%23 = trunc i64 %22 to i32
%24 = sext i32 %23 to i64
%25 = getelementptr inbounds i32*, i32** %21, i64 %24
%26 = load i32*, i32** %25
%27 = load %struct.TYPE_3__*, %struct.TYPE_3__** %3
%28 = getelementptr inbounds %struct.TYPE_3__, %struct.TYPE_3__* %27, i32 0, i32 2
store i32* %26, i32** %28
br label %29
29: ; preds = %16, %11
ret void
}

LLVM IR (-O2):
%struct.TYPE_3__ = type { i32, i32**, i32*, i64 }
@ns_s_max = global i64 0
define void @local_ns_setsection(%struct.TYPE_3__* nocapture %0, i64 %1) {
%3 = getelementptr inbounds %struct.TYPE_3__, %struct.TYPE_3__* %0, i64 0, i32 3
store i64 %1, i64* %3
%4 = load i64, i64* @ns_s_max
%5 = icmp eq i64 %4, %1
br i1 %5, label %13, label %6
6: ; preds = %2
%7 = getelementptr inbounds %struct.TYPE_3__, %struct.TYPE_3__* %0, i64 0, i32 1
%8 = load i32**, i32*** %7
%9 = shl i64 %1, 32
%10 = ashr exact i64 %9, 32
%11 = getelementptr inbounds i32*, i32** %8, i64 %10
%12 = load i32*, i32** %11
br label %13
13: ; preds = %2, %6
%14 = phi i32 [ 0, %6 ], [ -1, %2 ]
%15 = phi i32* [ %12, %6 ], [ null, %2 ]
%16 = getelementptr inbounds %struct.TYPE_3__, %struct.TYPE_3__* %0, i64 0, i32 0
store i32 %14, i32* %16
%17 = getelementptr inbounds %struct.TYPE_3__, %struct.TYPE_3__* %0, i64 0, i32 2
store i32* %15, i32** %17
ret void
}