#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*/ free(char *);
int m_len(int);
int /*<<< orphan*/ m_put(int, char **);
scalar_t__ mls(int, int);
char *strdup(char const *);
void v_kset(int var, const char *v, int row) {
  char *val = NULL;
  if (v)
    val = strdup(v);
  if (row < 0 || row >= m_len(var)) {
    m_put(var, &val);
  } else {
    char **d = (char **)mls(var, row);
    if (*d)
      free(*d);
    *d = val;
  }
}


x86 assembly (clang, -O0):
<v_kset>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
mov    %edi,-0x4(%rbp)
mov    %rsi,-0x10(%rbp)
mov    %edx,-0x14(%rbp)
movq   $0x0,-0x20(%rbp)
cmpq   $0x0,-0x10(%rbp)
je     1182 <v_kset+0x32>
mov    -0x10(%rbp),%rdi
call   1060 <strdup@plt>
mov    %rax,-0x20(%rbp)
cmpl   $0x0,-0x14(%rbp)
jl     11a7 <v_kset+0x57>
mov    -0x14(%rbp),%eax
mov    %eax,-0x2c(%rbp)
mov    -0x4(%rbp),%edi
call   1040 <m_len@plt>
mov    %eax,%ecx
mov    -0x2c(%rbp),%eax
cmp    %ecx,%eax
jl     11b8 <v_kset+0x68>
mov    -0x4(%rbp),%edi
lea    -0x20(%rbp),%rsi
call   1050 <m_put@plt>
jmp    11ec <v_kset+0x9c>
mov    -0x4(%rbp),%edi
mov    -0x14(%rbp),%esi
call   1070 <mls@plt>
mov    %rax,-0x28(%rbp)
mov    -0x28(%rbp),%rax
cmpq   $0x0,(%rax)
je     11e1 <v_kset+0x91>
mov    -0x28(%rbp),%rax
mov    (%rax),%rdi
call   1030 <free@plt>
mov    -0x20(%rbp),%rcx
mov    -0x28(%rbp),%rax
mov    %rcx,(%rax)
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<v_kset>:
push   %rbp
push   %r14
push   %rbx
sub    $0x10,%rsp
mov    %edx,%ebx
mov    %edi,%ebp
movq   $0x0,0x8(%rsp)
test   %rsi,%rsi
je     1180 <v_kset+0x30>
mov    %rsi,%rdi
call   1060 <strdup@plt>
mov    %rax,%r14
mov    %rax,0x8(%rsp)
test   %ebx,%ebx
jns    1187 <v_kset+0x37>
jmp    11b0 <v_kset+0x60>
xor    %r14d,%r14d
test   %ebx,%ebx
js     11b0 <v_kset+0x60>
mov    %ebp,%edi
call   1040 <m_len@plt>
cmp    %ebx,%eax
jle    11b0 <v_kset+0x60>
mov    %ebp,%edi
mov    %ebx,%esi
call   1070 <mls@plt>
mov    %rax,%rbx
mov    (%rax),%rdi
test   %rdi,%rdi
je     11ab <v_kset+0x5b>
call   1030 <free@plt>
mov    %r14,(%rbx)
jmp    11bc <v_kset+0x6c>
lea    0x8(%rsp),%rsi
mov    %ebp,%edi
call   1050 <m_put@plt>
add    $0x10,%rsp
pop    %rbx
pop    %r14
pop    %rbp
ret

LLVM IR (-O0):
define void @v_kset(i32 %0, i8* %1, i32 %2) {
%4 = alloca i32
%5 = alloca i8*
%6 = alloca i32
%7 = alloca i8*
%8 = alloca i8**
store i32 %0, i32* %4
store i8* %1, i8** %5
store i32 %2, i32* %6
store i8* null, i8** %7
%9 = load i8*, i8** %5
%10 = icmp ne i8* %9, null
br i1 %10, label %11, label %14
11: ; preds = %3
%12 = load i8*, i8** %5
%13 = call i8* @strdup(i8* %12)
store i8* %13, i8** %7
br label %14
14: ; preds = %11, %3
%15 = load i32, i32* %6
%16 = icmp slt i32 %15, 0
br i1 %16, label %22, label %17
17: ; preds = %14
%18 = load i32, i32* %6
%19 = load i32, i32* %4
%20 = call i32 @m_len(i32 %19)
%21 = icmp sge i32 %18, %20
br i1 %21, label %22, label %25
22: ; preds = %17, %14
%23 = load i32, i32* %4
%24 = call i32 @m_put(i32 %23, i8** %7)
br label %40
25: ; preds = %17
%26 = load i32, i32* %4
%27 = load i32, i32* %6
%28 = call i64 @mls(i32 %26, i32 %27)
%29 = inttoptr i64 %28 to i8**
store i8** %29, i8*** %8
%30 = load i8**, i8*** %8
%31 = load i8*, i8** %30
%32 = icmp ne i8* %31, null
br i1 %32, label %33, label %37
33: ; preds = %25
%34 = load i8**, i8*** %8
%35 = load i8*, i8** %34
%36 = call i32 @free(i8* %35)
br label %37
37: ; preds = %33, %25
%38 = load i8*, i8** %7
%39 = load i8**, i8*** %8
store i8* %38, i8** %39
br label %40
40: ; preds = %37, %22
ret void
}

LLVM IR (-O2):
define void @v_kset(i32 %0, i8* %1, i32 %2) {
%4 = alloca i8*
%5 = bitcast i8** %4 to i8*
store i8* null, i8** %4
%6 = icmp eq i8* %1, null
br i1 %6, label %9, label %7
7: ; preds = %3
%8 = tail call i8* @strdup(i8* %1)
store i8* %8, i8** %4
br label %9
9: ; preds = %7, %3
%10 = phi i8* [ %8, %7 ], [ null, %3 ]
%11 = icmp slt i32 %2, 0
br i1 %11, label %15, label %12
12: ; preds = %9
%13 = tail call i32 @m_len(i32 %0)
%14 = icmp sgt i32 %13, %2
br i1 %14, label %17, label %15
15: ; preds = %12, %9
%16 = call i32 @m_put(i32 %0, i8** %4)
br label %25
17: ; preds = %12
%18 = tail call i64 @mls(i32 %0, i32 %2)
%19 = inttoptr i64 %18 to i8**
%20 = load i8*, i8** %19
%21 = icmp eq i8* %20, null
br i1 %21, label %24, label %22
22: ; preds = %17
%23 = tail call i32 @free(i8* %20)
br label %24
24: ; preds = %22, %17
store i8* %10, i8** %19
br label %25
25: ; preds = %24, %15
ret void
}