#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 */
typedef int /*<<< orphan*/ value;
typedef int /*<<< orphan*/ publisher;
typedef int /*<<< orphan*/ property;

/* Variables and functions */
int /*<<< orphan*/ LipcClose(int);
char *LipcGetErrorString(int);
int LipcOpenNoName();
int LipcSetIntProperty(int, char *, char *, int /*<<< orphan*/);
int LipcSetStringProperty(int, char *, char *, char *);
int /*<<< orphan*/ atoi(char *);
int /*<<< orphan*/ printf(char *, ...);
int /*<<< orphan*/ snprintf(char *, int, char *, char *);
scalar_t__ strcmp(char *, char *);
int /*<<< orphan*/ usage(char *);
int main(int argc, char **argv) {
  char publisher[255];
  char property[255];
  char value[255];
  int lipc_handle, lipc_status;
  int is_int = 0;
  if (argc < 5) {
    usage(argv[0]);
  }
  if (strcmp(argv[1], "-i") == 0) {
    is_int = 1;
  } else if (strcmp(argv[1], "-s") != 0) {
    usage(argv[0]);
  }
  snprintf(publisher, sizeof(publisher), "%s", argv[2]);
  snprintf(property, sizeof(property), "%s", argv[3]);
  snprintf(value, sizeof(value), "%s", argv[4]);
  lipc_handle = LipcOpenNoName();
  if (!lipc_handle) {
    printf("Failed to open LIPC\n");
    return 1;
  }
  if (is_int) {
    lipc_status =
        LipcSetIntProperty(lipc_handle, publisher, property, atoi(value));
  } else {
    lipc_status =
        LipcSetStringProperty(lipc_handle, publisher, property, value);
  }
  LipcClose(lipc_handle);
  if (!lipc_status) {
    return 0;
  } else {
    printf("%s failed to set value for property %s (0x%x %s)\n", publisher,
           property, lipc_status, LipcGetErrorString(lipc_status));
    return lipc_status;
  }
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x350,%rsp
movl   $0x0,-0x4(%rbp)
mov    %edi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
movl   $0x0,-0x31c(%rbp)
cmpl   $0x5,-0x8(%rbp)
jge    11d9 <main+0x39>
mov    -0x10(%rbp),%rax
mov    (%rax),%rdi
call   10a0 <usage@plt>
mov    -0x10(%rbp),%rax
mov    0x8(%rax),%rdi
lea    0xe18(%rip),%rsi
call   1080 <strcmp@plt>
cmp    $0x0,%rax
jne    1206 <main+0x66>
movl   $0x1,-0x31c(%rbp)
jmp    1235 <main+0x95>
mov    -0x10(%rbp),%rax
mov    0x8(%rax),%rdi
lea    0xdee(%rip),%rsi
call   1080 <strcmp@plt>
cmp    $0x0,%rax
je     1230 <main+0x90>
mov    -0x10(%rbp),%rax
mov    (%rax),%rdi
call   10a0 <usage@plt>
jmp    1235 <main+0x95>
lea    -0x110(%rbp),%rdi
mov    -0x10(%rbp),%rax
mov    0x10(%rax),%rcx
mov    $0xff,%esi
lea    0xdb6(%rip),%rdx
call   1060 <snprintf@plt>
lea    -0x210(%rbp),%rdi
mov    -0x10(%rbp),%rax
mov    0x18(%rax),%rcx
mov    $0xff,%esi
lea    0xd96(%rip),%rdx
call   1060 <snprintf@plt>
lea    -0x310(%rbp),%rdi
mov    -0x10(%rbp),%rax
mov    0x20(%rax),%rcx
mov    $0xff,%esi
lea    0xd76(%rip),%rdx
call   1060 <snprintf@plt>
mov    $0x0,%al
call   1070 <LipcOpenNoName@plt>
mov    %eax,-0x314(%rbp)
cmpl   $0x0,-0x314(%rbp)
jne    12c9 <main+0x129>
lea    0xd53(%rip),%rdi
mov    $0x0,%al
call   1050 <printf@plt>
movl   $0x1,-0x4(%rbp)
jmp    13db <main+0x23b>
cmpl   $0x0,-0x31c(%rbp)
je     1330 <main+0x190>
mov    -0x314(%rbp),%eax
mov    %eax,-0x334(%rbp)
lea    -0x110(%rbp),%rax
mov    %rax,-0x330(%rbp)
lea    -0x210(%rbp),%rax
mov    %rax,-0x328(%rbp)
lea    -0x310(%rbp),%rdi
call   10c0 <atoi@plt>
mov    -0x334(%rbp),%edi
mov    -0x330(%rbp),%rsi
mov    -0x328(%rbp),%rdx
mov    %eax,%ecx
call   1040 <LipcSetIntProperty@plt>
mov    %eax,-0x318(%rbp)
jmp    1356 <main+0x1b6>
mov    -0x314(%rbp),%edi
lea    -0x110(%rbp),%rsi
lea    -0x210(%rbp),%rdx
lea    -0x310(%rbp),%rcx
call   1090 <LipcSetStringProperty@plt>
mov    %eax,-0x318(%rbp)
mov    -0x314(%rbp),%edi
call   1030 <LipcClose@plt>
cmpl   $0x0,-0x318(%rbp)
jne    137a <main+0x1da>
movl   $0x0,-0x4(%rbp)
jmp    13db <main+0x23b>
lea    -0x110(%rbp),%rax
mov    %rax,-0x348(%rbp)
lea    -0x210(%rbp),%rax
mov    %rax,-0x340(%rbp)
mov    -0x318(%rbp),%eax
mov    %eax,-0x338(%rbp)
mov    -0x318(%rbp),%edi
call   10b0 <LipcGetErrorString@plt>
mov    -0x348(%rbp),%rsi
mov    -0x340(%rbp),%rdx
mov    -0x338(%rbp),%ecx
mov    %rax,%r8
lea    0xc53(%rip),%rdi
mov    $0x0,%al
call   1050 <printf@plt>
mov    -0x318(%rbp),%eax
mov    %eax,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x350,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbp
push   %r14
push   %rbx
sub    $0x300,%rsp
mov    %rsi,%rbx
cmp    $0x4,%edi
jg     11cb <main+0x1b>
mov    (%rbx),%rdi
call   10b0 <usage@plt>
mov    0x8(%rbx),%rdi
lea    0xe2a(%rip),%rsi
call   1090 <strcmp@plt>
test   %rax,%rax
je     1202 <main+0x52>
mov    0x8(%rbx),%rdi
lea    0xe18(%rip),%rsi
call   1090 <strcmp@plt>
mov    $0x1,%r14b
test   %rax,%rax
je     1205 <main+0x55>
mov    (%rbx),%rdi
call   10b0 <usage@plt>
jmp    1205 <main+0x55>
xor    %r14d,%r14d
mov    0x10(%rbx),%rcx
lea    0xdf6(%rip),%rbp
lea    0x100(%rsp),%rdi
mov    $0xff,%esi
mov    %rbp,%rdx
call   1070 <snprintf@plt>
mov    0x18(%rbx),%rcx
mov    %rsp,%rdi
mov    $0xff,%esi
mov    %rbp,%rdx
call   1070 <snprintf@plt>
mov    0x20(%rbx),%rcx
lea    0x200(%rsp),%rdi
mov    $0xff,%esi
mov    %rbp,%rdx
call   1070 <snprintf@plt>
xor    %eax,%eax
call   1080 <LipcOpenNoName@plt>
test   %eax,%eax
je     1280 <main+0xd0>
mov    %eax,%ebx
test   %r14b,%r14b
je     1293 <main+0xe3>
lea    0x100(%rsp),%rsi
mov    %rsp,%rdx
lea    0x200(%rsp),%rcx
mov    %ebx,%edi
call   10a0 <LipcSetStringProperty@plt>
jmp    12b4 <main+0x104>
lea    0xdb4(%rip),%rdi
call   1030 <puts@plt>
mov    $0x1,%ebp
jmp    12ea <main+0x13a>
lea    0x200(%rsp),%rdi
call   10d0 <atoi@plt>
lea    0x100(%rsp),%rsi
mov    %rsp,%rdx
mov    %ebx,%edi
mov    %eax,%ecx
call   1050 <LipcSetIntProperty@plt>
mov    %eax,%ebp
mov    %ebx,%edi
call   1040 <LipcClose@plt>
test   %ebp,%ebp
je     12e8 <main+0x138>
mov    %ebp,%edi
call   10c0 <LipcGetErrorString@plt>
lea    0xd3a(%rip),%rdi
lea    0x100(%rsp),%rsi
mov    %rsp,%rdx
mov    %ebp,%ecx
mov    %rax,%r8
xor    %eax,%eax
call   1060 <printf@plt>
jmp    12ea <main+0x13a>
xor    %ebp,%ebp
mov    %ebp,%eax
add    $0x300,%rsp
pop    %rbx
pop    %r14
pop    %rbp
ret

LLVM IR (-O0):
@.str = [3 x i8] c"-i\00"
@.str.1 = [3 x i8] c"-s\00"
@.str.2 = [3 x i8] c"%s\00"
@.str.3 = [21 x i8] c"Failed to open LIPC\0A\00"
@.str.4 = [50 x i8] c"%s failed to set value for property %s (0x%x %s)\0A\00"
define i32 @main(i32 %0, i8** %1) {
%3 = alloca i32
%4 = alloca i32
%5 = alloca i8**
%6 = alloca [255 x i8]
%7 = alloca [255 x i8]
%8 = alloca [255 x i8]
%9 = alloca i32
%10 = alloca i32
%11 = alloca i32
store i32 0, i32* %3
store i32 %0, i32* %4
store i8** %1, i8*** %5
store i32 0, i32* %11
%12 = load i32, i32* %4
%13 = icmp slt i32 %12, 5
br i1 %13, label %14, label %19
14: ; preds = %2
%15 = load i8**, i8*** %5
%16 = getelementptr inbounds i8*, i8** %15, i64 0
%17 = load i8*, i8** %16
%18 = call i32 @usage(i8* %17)
br label %19
19: ; preds = %14, %2
%20 = load i8**, i8*** %5
%21 = getelementptr inbounds i8*, i8** %20, i64 1
%22 = load i8*, i8** %21
%23 = call i64 @strcmp(i8* %22, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str, i64 0, i64 0))
%24 = icmp eq i64 %23, 0
br i1 %24, label %25, label %26
25: ; preds = %19
store i32 1, i32* %11
br label %38
26: ; preds = %19
%27 = load i8**, i8*** %5
%28 = getelementptr inbounds i8*, i8** %27, i64 1
%29 = load i8*, i8** %28
%30 = call i64 @strcmp(i8* %29, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0))
%31 = icmp ne i64 %30, 0
br i1 %31, label %32, label %37
32: ; preds = %26
%33 = load i8**, i8*** %5
%34 = getelementptr inbounds i8*, i8** %33, i64 0
%35 = load i8*, i8** %34
%36 = call i32 @usage(i8* %35)
br label %37
37: ; preds = %32, %26
br label %38
38: ; preds = %37, %25
%39 = getelementptr inbounds [255 x i8], [255 x i8]* %6, i64 0, i64 0
%40 = load i8**, i8*** %5
%41 = getelementptr inbounds i8*, i8** %40, i64 2
%42 = load i8*, i8** %41
%43 = call i32 @snprintf(i8* %39, i32 255, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.2, i64 0, i64 0), i8* %42)
%44 = getelementptr inbounds [255 x i8], [255 x i8]* %7, i64 0, i64 0
%45 = load i8**, i8*** %5
%46 = getelementptr inbounds i8*, i8** %45, i64 3
%47 = load i8*, i8** %46
%48 = call i32 @snprintf(i8* %44, i32 255, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.2, i64 0, i64 0), i8* %47)
%49 = getelementptr inbounds [255 x i8], [255 x i8]* %8, i64 0, i64 0
%50 = load i8**, i8*** %5
%51 = getelementptr inbounds i8*, i8** %50, i64 4
%52 = load i8*, i8** %51
%53 = call i32 @snprintf(i8* %49, i32 255, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.2, i64 0, i64 0), i8* %52)
%54 = call i32 (...) @LipcOpenNoName()
store i32 %54, i32* %9
%55 = load i32, i32* %9
%56 = icmp ne i32 %55, 0
br i1 %56, label %59, label %57
57: ; preds = %38
%58 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([21 x i8], [21 x i8]* @.str.3, i64 0, i64 0))
store i32 1, i32* %3
br label %89
59: ; preds = %38
%60 = load i32, i32* %11
%61 = icmp ne i32 %60, 0
br i1 %61, label %62, label %69
62: ; preds = %59
%63 = load i32, i32* %9
%64 = getelementptr inbounds [255 x i8], [255 x i8]* %6, i64 0, i64 0
%65 = getelementptr inbounds [255 x i8], [255 x i8]* %7, i64 0, i64 0
%66 = getelementptr inbounds [255 x i8], [255 x i8]* %8, i64 0, i64 0
%67 = call i32 @atoi(i8* %66)
%68 = call i32 @LipcSetIntProperty(i32 %63, i8* %64, i8* %65, i32 %67)
store i32 %68, i32* %10
br label %75
69: ; preds = %59
%70 = load i32, i32* %9
%71 = getelementptr inbounds [255 x i8], [255 x i8]* %6, i64 0, i64 0
%72 = getelementptr inbounds [255 x i8], [255 x i8]* %7, i64 0, i64 0
%73 = getelementptr inbounds [255 x i8], [255 x i8]* %8, i64 0, i64 0
%74 = call i32 @LipcSetStringProperty(i32 %70, i8* %71, i8* %72, i8* %73)
store i32 %74, i32* %10
br label %75
75: ; preds = %69, %62
%76 = load i32, i32* %9
%77 = call i32 @LipcClose(i32 %76)
%78 = load i32, i32* %10
%79 = icmp ne i32 %78, 0
br i1 %79, label %81, label %80
80: ; preds = %75
store i32 0, i32* %3
br label %89
81: ; preds = %75
%82 = getelementptr inbounds [255 x i8], [255 x i8]* %6, i64 0, i64 0
%83 = getelementptr inbounds [255 x i8], [255 x i8]* %7, i64 0, i64 0
%84 = load i32, i32* %10
%85 = load i32, i32* %10
%86 = call i8* @LipcGetErrorString(i32 %85)
%87 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([50 x i8], [50 x i8]* @.str.4, i64 0, i64 0), i8* %82, i8* %83, i32 %84, i8* %86)
%88 = load i32, i32* %10
store i32 %88, i32* %3
br label %89
89: ; preds = %81, %80, %57
%90 = load i32, i32* %3
ret i32 %90
}

LLVM IR (-O2):
@.str = [3 x i8] c"-i\00"
@.str.1 = [3 x i8] c"-s\00"
@.str.2 = [3 x i8] c"%s\00"
@.str.4 = [50 x i8] c"%s failed to set value for property %s (0x%x %s)\0A\00"
@str = [20 x i8] c"Failed to open LIPC\00"
define i32 @main(i32 %0, i8** nocapture %1) {
%3 = alloca [255 x i8]
%4 = alloca [255 x i8]
%5 = alloca [255 x i8]
%6 = getelementptr inbounds [255 x i8], [255 x i8]* %3, i64 0, i64 0
%7 = getelementptr inbounds [255 x i8], [255 x i8]* %4, i64 0, i64 0
%8 = getelementptr inbounds [255 x i8], [255 x i8]* %5, i64 0, i64 0
%9 = icmp slt i32 %0, 5
br i1 %9, label %10, label %13
10: ; preds = %2
%11 = load i8*, i8** %1
%12 = tail call i32 @usage(i8* %11)
br label %13
13: ; preds = %10, %2
%14 = getelementptr inbounds i8*, i8** %1, i64 1
%15 = load i8*, i8** %14
%16 = tail call i64 @strcmp(i8* %15, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str, i64 0, i64 0))
%17 = icmp eq i64 %16, 0
br i1 %17, label %25, label %18
18: ; preds = %13
%19 = load i8*, i8** %14
%20 = tail call i64 @strcmp(i8* %19, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0))
%21 = icmp eq i64 %20, 0
br i1 %21, label %25, label %22
22: ; preds = %18
%23 = load i8*, i8** %1
%24 = tail call i32 @usage(i8* %23)
br label %25
25: ; preds = %13, %18, %22
%26 = phi i1 [ true, %18 ], [ true, %22 ], [ false, %13 ]
%27 = getelementptr inbounds i8*, i8** %1, i64 2
%28 = load i8*, i8** %27
%29 = call i32 @snprintf(i8* %6, i32 255, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.2, i64 0, i64 0), i8* %28)
%30 = getelementptr inbounds i8*, i8** %1, i64 3
%31 = load i8*, i8** %30
%32 = call i32 @snprintf(i8* %7, i32 255, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.2, i64 0, i64 0), i8* %31)
%33 = getelementptr inbounds i8*, i8** %1, i64 4
%34 = load i8*, i8** %33
%35 = call i32 @snprintf(i8* %8, i32 255, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.2, i64 0, i64 0), i8* %34)
%36 = call i32 (...) @LipcOpenNoName()
%37 = icmp eq i32 %36, 0
br i1 %37, label %38, label %40
38: ; preds = %25
%39 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([20 x i8], [20 x i8]* @str, i64 0, i64 0))
br label %53
40: ; preds = %25
br i1 %26, label %44, label %41
41: ; preds = %40
%42 = call i32 @atoi(i8* %8)
%43 = call i32 @LipcSetIntProperty(i32 %36, i8* %6, i8* %7, i32 %42)
br label %46
44: ; preds = %40
%45 = call i32 @LipcSetStringProperty(i32 %36, i8* %6, i8* %7, i8* %8)
br label %46
46: ; preds = %44, %41
%47 = phi i32 [ %43, %41 ], [ %45, %44 ]
%48 = call i32 @LipcClose(i32 %36)
%49 = icmp eq i32 %47, 0
br i1 %49, label %53, label %50
50: ; preds = %46
%51 = call i8* @LipcGetErrorString(i32 %47)
%52 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([50 x i8], [50 x i8]* @.str.4, i64 0, i64 0), i8* %6, i8* %7, i32 %47, i8* %51)
br label %53
53: ; preds = %46, %50, %38
%54 = phi i32 [ %47, %50 ], [ 1, %38 ], [ 0, %46 ]
ret i32 %54
}