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

/* Variables and functions */
int /*<<< orphan*/ LipcClose(int);
int /*<<< orphan*/ LipcFreeString(char *);
char *LipcGetErrorString(int);
int LipcGetIntProperty(int, char *, char *, int *);
int LipcGetStringProperty(int, char *, char *, char **);
int LipcOpenNoName();
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 *svalue;
  int ivalue;
  int lipc_handle, lipc_status;
  int is_int = 0;
  if (argc < 4) {
    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]);
  lipc_handle = LipcOpenNoName();
  if (!lipc_handle) {
    printf("Failed to open LIPC\n");
    return 1;
  }
  if (is_int) {
    lipc_status = LipcGetIntProperty(lipc_handle, publisher, property, &ivalue);
    if (!lipc_status)
      printf("%d\n", ivalue);
  } else {
    lipc_status =
        LipcGetStringProperty(lipc_handle, publisher, property, &svalue);
    if (!lipc_status) {
      printf("%s\n", svalue);
      LipcFreeString(svalue);
    }
  }
  LipcClose(lipc_handle);
  if (!lipc_status) {
    return 0;
  } else {
    printf("%s failed to get value for property %s (0x%x %s)\n", publisher,
           property, lipc_status, LipcGetErrorString(lipc_status));
    return 0;
  }
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x240,%rsp
movl   $0x0,-0x4(%rbp)
mov    %edi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
movl   $0x0,-0x228(%rbp)
cmpl   $0x4,-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,-0x228(%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   1050 <snprintf@plt>
lea    -0x210(%rbp),%rdi
mov    -0x10(%rbp),%rax
mov    0x18(%rax),%rcx
mov    $0xff,%esi
lea    0xd96(%rip),%rdx
call   1050 <snprintf@plt>
mov    $0x0,%al
call   1060 <LipcOpenNoName@plt>
mov    %eax,-0x220(%rbp)
cmpl   $0x0,-0x220(%rbp)
jne    12a9 <main+0x109>
lea    0xd73(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
movl   $0x1,-0x4(%rbp)
jmp    13de <main+0x23e>
cmpl   $0x0,-0x228(%rbp)
je     1302 <main+0x162>
mov    -0x220(%rbp),%edi
lea    -0x110(%rbp),%rsi
lea    -0x210(%rbp),%rdx
lea    -0x21c(%rbp),%rcx
call   10c0 <LipcGetIntProperty@plt>
mov    %eax,-0x224(%rbp)
cmpl   $0x0,-0x224(%rbp)
jne    12fd <main+0x15d>
mov    -0x21c(%rbp),%esi
lea    0xd28(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
jmp    135b <main+0x1bb>
mov    -0x220(%rbp),%edi
lea    -0x110(%rbp),%rsi
lea    -0x210(%rbp),%rdx
lea    -0x218(%rbp),%rcx
call   1090 <LipcGetStringProperty@plt>
mov    %eax,-0x224(%rbp)
cmpl   $0x0,-0x224(%rbp)
jne    1356 <main+0x1b6>
mov    -0x218(%rbp),%rsi
lea    0xcdf(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
mov    -0x218(%rbp),%rdi
call   1070 <LipcFreeString@plt>
jmp    135b <main+0x1bb>
mov    -0x220(%rbp),%edi
call   1030 <LipcClose@plt>
cmpl   $0x0,-0x224(%rbp)
jne    137f <main+0x1df>
movl   $0x0,-0x4(%rbp)
jmp    13de <main+0x23e>
lea    -0x110(%rbp),%rax
mov    %rax,-0x240(%rbp)
lea    -0x210(%rbp),%rax
mov    %rax,-0x238(%rbp)
mov    -0x224(%rbp),%eax
mov    %eax,-0x22c(%rbp)
mov    -0x224(%rbp),%edi
call   10b0 <LipcGetErrorString@plt>
mov    -0x240(%rbp),%rsi
mov    -0x238(%rbp),%rdx
mov    -0x22c(%rbp),%ecx
mov    %rax,%r8
lea    0xc56(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
movl   $0x0,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x240,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbp
push   %r14
push   %rbx
sub    $0x210,%rsp
mov    %rsi,%rbx
cmp    $0x3,%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    0x110(%rsp),%rdi
mov    $0xff,%esi
mov    %rbp,%rdx
call   1060 <snprintf@plt>
mov    0x18(%rbx),%rcx
lea    0x10(%rsp),%rdi
mov    $0xff,%esi
mov    %rbp,%rdx
call   1060 <snprintf@plt>
xor    %eax,%eax
call   1070 <LipcOpenNoName@plt>
test   %eax,%eax
je     1282 <main+0xd2>
mov    %eax,%ebx
lea    0x110(%rsp),%rsi
lea    0x10(%rsp),%rdx
lea    0x8(%rsp),%rcx
mov    %eax,%edi
test   %r14b,%r14b
je     1295 <main+0xe5>
call   10a0 <LipcGetStringProperty@plt>
mov    %eax,%ebp
test   %eax,%eax
jne    12a0 <main+0xf0>
mov    0x8(%rsp),%rdi
call   1030 <puts@plt>
mov    0x8(%rsp),%rdi
call   1080 <LipcFreeString@plt>
jmp    12e4 <main+0x134>
lea    0xdb6(%rip),%rdi
call   1030 <puts@plt>
mov    $0x1,%ebx
jmp    12ed <main+0x13d>
call   10d0 <LipcGetIntProperty@plt>
mov    %eax,%ebp
test   %eax,%eax
je     12d2 <main+0x122>
mov    %ebx,%edi
call   1040 <LipcClose@plt>
mov    %ebp,%edi
call   10c0 <LipcGetErrorString@plt>
lea    0xd58(%rip),%rdi
xor    %ebx,%ebx
lea    0x110(%rsp),%rsi
lea    0x10(%rsp),%rdx
mov    %ebp,%ecx
mov    %rax,%r8
xor    %eax,%eax
call   1050 <printf@plt>
jmp    12ed <main+0x13d>
mov    0x8(%rsp),%esi
lea    0xd2c(%rip),%rdi
xor    %eax,%eax
call   1050 <printf@plt>
mov    %ebx,%edi
call   1040 <LipcClose@plt>
xor    %ebx,%ebx
mov    %ebx,%eax
add    $0x210,%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 = [4 x i8] c"%d\0A\00"
@.str.5 = [4 x i8] c"%s\0A\00"
@.str.6 = [50 x i8] c"%s failed to get 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 i8*
%9 = alloca i32
%10 = alloca i32
%11 = alloca i32
%12 = alloca i32
store i32 0, i32* %3
store i32 %0, i32* %4
store i8** %1, i8*** %5
store i32 0, i32* %12
%13 = load i32, i32* %4
%14 = icmp slt i32 %13, 4
br i1 %14, label %15, label %20
15: ; preds = %2
%16 = load i8**, i8*** %5
%17 = getelementptr inbounds i8*, i8** %16, i64 0
%18 = load i8*, i8** %17
%19 = call i32 @usage(i8* %18)
br label %20
20: ; preds = %15, %2
%21 = load i8**, i8*** %5
%22 = getelementptr inbounds i8*, i8** %21, i64 1
%23 = load i8*, i8** %22
%24 = call i64 @strcmp(i8* %23, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str, i64 0, i64 0))
%25 = icmp eq i64 %24, 0
br i1 %25, label %26, label %27
26: ; preds = %20
store i32 1, i32* %12
br label %39
27: ; preds = %20
%28 = load i8**, i8*** %5
%29 = getelementptr inbounds i8*, i8** %28, i64 1
%30 = load i8*, i8** %29
%31 = call i64 @strcmp(i8* %30, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0))
%32 = icmp ne i64 %31, 0
br i1 %32, label %33, label %38
33: ; preds = %27
%34 = load i8**, i8*** %5
%35 = getelementptr inbounds i8*, i8** %34, i64 0
%36 = load i8*, i8** %35
%37 = call i32 @usage(i8* %36)
br label %38
38: ; preds = %33, %27
br label %39
39: ; preds = %38, %26
%40 = getelementptr inbounds [255 x i8], [255 x i8]* %6, i64 0, i64 0
%41 = load i8**, i8*** %5
%42 = getelementptr inbounds i8*, i8** %41, i64 2
%43 = load i8*, i8** %42
%44 = call i32 @snprintf(i8* %40, i32 255, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.2, i64 0, i64 0), i8* %43)
%45 = getelementptr inbounds [255 x i8], [255 x i8]* %7, i64 0, i64 0
%46 = load i8**, i8*** %5
%47 = getelementptr inbounds i8*, i8** %46, i64 3
%48 = load i8*, i8** %47
%49 = call i32 @snprintf(i8* %45, i32 255, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.2, i64 0, i64 0), i8* %48)
%50 = call i32 (...) @LipcOpenNoName()
store i32 %50, i32* %10
%51 = load i32, i32* %10
%52 = icmp ne i32 %51, 0
br i1 %52, label %55, label %53
53: ; preds = %39
%54 = 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 %95
55: ; preds = %39
%56 = load i32, i32* %12
%57 = icmp ne i32 %56, 0
br i1 %57, label %58, label %69
58: ; preds = %55
%59 = load i32, i32* %10
%60 = getelementptr inbounds [255 x i8], [255 x i8]* %6, i64 0, i64 0
%61 = getelementptr inbounds [255 x i8], [255 x i8]* %7, i64 0, i64 0
%62 = call i32 @LipcGetIntProperty(i32 %59, i8* %60, i8* %61, i32* %9)
store i32 %62, i32* %11
%63 = load i32, i32* %11
%64 = icmp ne i32 %63, 0
br i1 %64, label %68, label %65
65: ; preds = %58
%66 = load i32, i32* %9
%67 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.4, i64 0, i64 0), i32 %66)
br label %68
68: ; preds = %65, %58
br label %82
69: ; preds = %55
%70 = load i32, i32* %10
%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 = call i32 @LipcGetStringProperty(i32 %70, i8* %71, i8* %72, i8** %8)
store i32 %73, i32* %11
%74 = load i32, i32* %11
%75 = icmp ne i32 %74, 0
br i1 %75, label %81, label %76
76: ; preds = %69
%77 = load i8*, i8** %8
%78 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.5, i64 0, i64 0), i8* %77)
%79 = load i8*, i8** %8
%80 = call i32 @LipcFreeString(i8* %79)
br label %81
81: ; preds = %76, %69
br label %82
82: ; preds = %81, %68
%83 = load i32, i32* %10
%84 = call i32 @LipcClose(i32 %83)
%85 = load i32, i32* %11
%86 = icmp ne i32 %85, 0
br i1 %86, label %88, label %87
87: ; preds = %82
store i32 0, i32* %3
br label %95
88: ; preds = %82
%89 = getelementptr inbounds [255 x i8], [255 x i8]* %6, i64 0, i64 0
%90 = getelementptr inbounds [255 x i8], [255 x i8]* %7, i64 0, i64 0
%91 = load i32, i32* %11
%92 = load i32, i32* %11
%93 = call i8* @LipcGetErrorString(i32 %92)
%94 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([50 x i8], [50 x i8]* @.str.6, i64 0, i64 0), i8* %89, i8* %90, i32 %91, i8* %93)
store i32 0, i32* %3
br label %95
95: ; preds = %88, %87, %53
%96 = load i32, i32* %3
ret i32 %96
}

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 = [4 x i8] c"%d\0A\00"
@.str.6 = [50 x i8] c"%s failed to get 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 i8*
%6 = alloca i32
%7 = getelementptr inbounds [255 x i8], [255 x i8]* %3, i64 0, i64 0
%8 = getelementptr inbounds [255 x i8], [255 x i8]* %4, i64 0, i64 0
%9 = bitcast i8** %5 to i8*
%10 = bitcast i32* %6 to i8*
%11 = icmp slt i32 %0, 4
br i1 %11, label %12, label %15
12: ; preds = %2
%13 = load i8*, i8** %1
%14 = tail call i32 @usage(i8* %13)
br label %15
15: ; preds = %12, %2
%16 = getelementptr inbounds i8*, i8** %1, i64 1
%17 = load i8*, i8** %16
%18 = tail call i64 @strcmp(i8* %17, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str, i64 0, i64 0))
%19 = icmp eq i64 %18, 0
br i1 %19, label %27, label %20
20: ; preds = %15
%21 = load i8*, i8** %16
%22 = tail call i64 @strcmp(i8* %21, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0))
%23 = icmp eq i64 %22, 0
br i1 %23, label %27, label %24
24: ; preds = %20
%25 = load i8*, i8** %1
%26 = tail call i32 @usage(i8* %25)
br label %27
27: ; preds = %15, %20, %24
%28 = phi i1 [ true, %20 ], [ true, %24 ], [ false, %15 ]
%29 = getelementptr inbounds i8*, i8** %1, i64 2
%30 = load i8*, i8** %29
%31 = call i32 @snprintf(i8* %7, i32 255, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.2, i64 0, i64 0), i8* %30)
%32 = getelementptr inbounds i8*, i8** %1, i64 3
%33 = load i8*, i8** %32
%34 = call i32 @snprintf(i8* %8, i32 255, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.2, i64 0, i64 0), i8* %33)
%35 = call i32 (...) @LipcOpenNoName()
%36 = icmp eq i32 %35, 0
br i1 %36, label %37, label %39
37: ; preds = %27
%38 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([20 x i8], [20 x i8]* @str, i64 0, i64 0))
br label %61
39: ; preds = %27
br i1 %28, label %46, label %40
40: ; preds = %39
%41 = call i32 @LipcGetIntProperty(i32 %35, i8* %7, i8* %8, i32* %6)
%42 = icmp eq i32 %41, 0
br i1 %42, label %43, label %56
43: ; preds = %40
%44 = load i32, i32* %6
%45 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([4 x i8], [4 x i8]* @.str.4, i64 0, i64 0), i32 %44)
br label %54
46: ; preds = %39
%47 = call i32 @LipcGetStringProperty(i32 %35, i8* %7, i8* %8, i8** %5)
%48 = icmp eq i32 %47, 0
br i1 %48, label %49, label %56
49: ; preds = %46
%50 = load i8*, i8** %5
%51 = call i32 @puts(i8* dereferenceable(1) %50)
%52 = load i8*, i8** %5
%53 = call i32 @LipcFreeString(i8* %52)
br label %54
54: ; preds = %43, %49
%55 = call i32 @LipcClose(i32 %35)
br label %61
56: ; preds = %40, %46
%57 = phi i32 [ %41, %40 ], [ %47, %46 ]
%58 = call i32 @LipcClose(i32 %35)
%59 = call i8* @LipcGetErrorString(i32 %57)
%60 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([50 x i8], [50 x i8]* @.str.6, i64 0, i64 0), i8* %7, i8* %8, i32 %57, i8* %59)
br label %61
61: ; preds = %54, %56, %37
%62 = phi i32 [ 0, %56 ], [ 1, %37 ], [ 0, %54 ]
ret i32 %62
}