#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 */
struct ServiceInfo {
  int dummy;
};

/* Variables and functions */
char *dvbcommand(char *, int /*<<< orphan*/);
int /*<<< orphan*/ free(char *);
struct ServiceInfo *serviceInfoParse(char *);
int /*<<< orphan*/ sprintf(char *, char *, char *);
char *xmalloc(int);
struct ServiceInfo *getServiceInfo(char *service) {
  struct ServiceInfo *SI;
  char *si;
  char *cmd;
  cmd = xmalloc(256);
  sprintf(cmd, "serviceinfo '%s'", service);
  si = dvbcommand(cmd, 0);
  SI = serviceInfoParse(si);
  free(si);
  free(cmd);
  return SI;
}


x86 assembly (clang, -O0):
<getServiceInfo>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %rdi,-0x8(%rbp)
mov    $0x100,%edi
call   1050 <xmalloc@plt>
mov    %rax,-0x20(%rbp)
mov    -0x20(%rbp),%rdi
mov    -0x8(%rbp),%rdx
lea    0xe87(%rip),%rsi
call   1070 <sprintf@plt>
mov    -0x20(%rbp),%rdi
xor    %esi,%esi
call   1060 <dvbcommand@plt>
mov    %rax,-0x18(%rbp)
mov    -0x18(%rbp),%rdi
call   1040 <serviceInfoParse@plt>
mov    %rax,-0x10(%rbp)
mov    -0x18(%rbp),%rdi
call   1030 <free@plt>
mov    -0x20(%rbp),%rdi
call   1030 <free@plt>
mov    -0x10(%rbp),%rax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<getServiceInfo>:
push   %r15
push   %r14
push   %rbx
mov    %rdi,%r14
mov    $0x100,%edi
call   1050 <xmalloc@plt>
mov    %rax,%r15
lea    0xe94(%rip),%rsi
mov    %rax,%rdi
mov    %r14,%rdx
call   1070 <sprintf@plt>
mov    %r15,%rdi
xor    %esi,%esi
call   1060 <dvbcommand@plt>
mov    %rax,%rbx
mov    %rax,%rdi
call   1040 <serviceInfoParse@plt>
mov    %rax,%r14
mov    %rbx,%rdi
call   1030 <free@plt>
mov    %r15,%rdi
call   1030 <free@plt>
mov    %r14,%rax
pop    %rbx
pop    %r14
pop    %r15
ret

LLVM IR (-O0):
%struct.ServiceInfo = type { i32 }
@.str = [17 x i8] c"serviceinfo '%s'\00"
define %struct.ServiceInfo* @getServiceInfo(i8* %0) {
%2 = alloca i8*
%3 = alloca %struct.ServiceInfo*
%4 = alloca i8*
%5 = alloca i8*
store i8* %0, i8** %2
%6 = call i8* @xmalloc(i32 256)
store i8* %6, i8** %5
%7 = load i8*, i8** %5
%8 = load i8*, i8** %2
%9 = call i32 @sprintf(i8* %7, i8* getelementptr inbounds ([17 x i8], [17 x i8]* @.str, i64 0, i64 0), i8* %8)
%10 = load i8*, i8** %5
%11 = call i8* @dvbcommand(i8* %10, i32 0)
store i8* %11, i8** %4
%12 = load i8*, i8** %4
%13 = call %struct.ServiceInfo* @serviceInfoParse(i8* %12)
store %struct.ServiceInfo* %13, %struct.ServiceInfo** %3
%14 = load i8*, i8** %4
%15 = call i32 @free(i8* %14)
%16 = load i8*, i8** %5
%17 = call i32 @free(i8* %16)
%18 = load %struct.ServiceInfo*, %struct.ServiceInfo** %3
ret %struct.ServiceInfo* %18
}

LLVM IR (-O2):
%struct.ServiceInfo = type { i32 }
@.str = [17 x i8] c"serviceinfo '%s'\00"
define %struct.ServiceInfo* @getServiceInfo(i8* %0) {
%2 = tail call i8* @xmalloc(i32 256)
%3 = tail call i32 @sprintf(i8* dereferenceable(1) %2, i8* dereferenceable(1) getelementptr inbounds ([17 x i8], [17 x i8]* @.str, i64 0, i64 0), i8* %0)
%4 = tail call i8* @dvbcommand(i8* %2, i32 0)
%5 = tail call %struct.ServiceInfo* @serviceInfoParse(i8* %4)
%6 = tail call i32 @free(i8* %4)
%7 = tail call i32 @free(i8* %2)
ret %struct.ServiceInfo* %5
}