#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*/ FILE;

/* Variables and functions */
int getline(char **, int /*<<< orphan*/ *, int /*<<< orphan*/ *);
int /*<<< orphan*/ pclose(int /*<<< orphan*/ *);
int /*<<< orphan*/ *popen(char *, char *);
char *psys_lsb_distributor_id(void) {
  FILE *pipe;
  pipe = popen("lsb_release -si", "r");
  if (pipe) {
    char *id;
    int nbytes;
    id = NULL;
    nbytes = getline(&id, NULL, pipe);
    pclose(pipe);
    if (nbytes != -1)
      return id;
  }
  return NULL;
}


x86 assembly (clang, -O0):
<psys_lsb_distributor_id>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
lea    0xec1(%rip),%rdi
lea    0xeca(%rip),%rsi
call   1040 <popen@plt>
mov    %rax,-0x10(%rbp)
cmpq   $0x0,-0x10(%rbp)
je     119b <psys_lsb_distributor_id+0x6b>
movq   $0x0,-0x18(%rbp)
mov    -0x10(%rbp),%rdx
lea    -0x18(%rbp),%rdi
xor    %eax,%eax
mov    %eax,%esi
call   1050 <getline@plt>
mov    %eax,-0x1c(%rbp)
mov    -0x10(%rbp),%rdi
call   1030 <pclose@plt>
cmpl   $0xffffffff,-0x1c(%rbp)
je     1196 <psys_lsb_distributor_id+0x66>
mov    -0x18(%rbp),%rax
mov    %rax,-0x8(%rbp)
jmp    11a3 <psys_lsb_distributor_id+0x73>
jmp    119b <psys_lsb_distributor_id+0x6b>
movq   $0x0,-0x8(%rbp)
mov    -0x8(%rbp),%rax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<psys_lsb_distributor_id>:
push   %rbp
push   %rbx
push   %rax
lea    0xec6(%rip),%rdi
lea    0xecf(%rip),%rsi
call   1040 <popen@plt>
test   %rax,%rax
je     1178 <psys_lsb_distributor_id+0x48>
mov    %rax,%rbx
movq   $0x0,(%rsp)
mov    %rsp,%rdi
xor    %esi,%esi
mov    %rax,%rdx
call   1050 <getline@plt>
mov    %eax,%ebp
mov    %rbx,%rdi
call   1030 <pclose@plt>
cmp    $0xffffffff,%ebp
je     1178 <psys_lsb_distributor_id+0x48>
mov    (%rsp),%rax
jmp    117a <psys_lsb_distributor_id+0x4a>
xor    %eax,%eax
add    $0x8,%rsp
pop    %rbx
pop    %rbp
ret

LLVM IR (-O0):
@.str = [16 x i8] c"lsb_release -si\00"
@.str.1 = [2 x i8] c"r\00"
define i8* @psys_lsb_distributor_id() {
%1 = alloca i8*
%2 = alloca i32*
%3 = alloca i8*
%4 = alloca i32
%5 = call i32* @popen(i8* getelementptr inbounds ([16 x i8], [16 x i8]* @.str, i64 0, i64 0), i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.1, i64 0, i64 0))
store i32* %5, i32** %2
%6 = load i32*, i32** %2
%7 = icmp ne i32* %6, null
br i1 %7, label %8, label %18
8: ; preds = %0
store i8* null, i8** %3
%9 = load i32*, i32** %2
%10 = call i32 @getline(i8** %3, i32* null, i32* %9)
store i32 %10, i32* %4
%11 = load i32*, i32** %2
%12 = call i32 @pclose(i32* %11)
%13 = load i32, i32* %4
%14 = icmp ne i32 %13, -1
br i1 %14, label %15, label %17
15: ; preds = %8
%16 = load i8*, i8** %3
store i8* %16, i8** %1
br label %19
17: ; preds = %8
br label %18
18: ; preds = %17, %0
store i8* null, i8** %1
br label %19
19: ; preds = %18, %15
%20 = load i8*, i8** %1
ret i8* %20
}

LLVM IR (-O2):
@.str = [16 x i8] c"lsb_release -si\00"
@.str.1 = [2 x i8] c"r\00"
define i8* @psys_lsb_distributor_id() {
%1 = alloca i8*
%2 = tail call i32* @popen(i8* getelementptr inbounds ([16 x i8], [16 x i8]* @.str, i64 0, i64 0), i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.1, i64 0, i64 0))
%3 = icmp eq i32* %2, null
br i1 %3, label %10, label %4
4: ; preds = %0
%5 = bitcast i8** %1 to i8*
store i8* null, i8** %1
%6 = call i32 @getline(i8** %1, i32* null, i32* %2)
%7 = call i32 @pclose(i32* %2)
%8 = icmp eq i32 %6, -1
%9 = load i8*, i8** %1
br i1 %8, label %10, label %11
10: ; preds = %4, %0
br label %11
11: ; preds = %4, %10
%12 = phi i8* [ null, %10 ], [ %9, %4 ]
ret i8* %12
}