#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 group {
  char *gr_name;
  char *gr_passwd;
  int gr_gid;
};

/* Variables and functions */
struct group *getgrnam(char *);
int /*<<< orphan*/ printf(char *, ...);
int main(int argc, char **argv) {
  struct group *grp;
  int i;
  if (argc < 2)
    grp = getgrnam("root");
  else
    grp = getgrnam(argv[1]);
  if (grp == NULL) {
    printf("Not found\n");
    return -1;
  }
  printf("group name=%s,group_passwd=%s,group_gid=%d\n", grp->gr_name,
         grp->gr_passwd, grp->gr_gid);
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
movl   $0x0,-0x4(%rbp)
mov    %edi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
cmpl   $0x2,-0x8(%rbp)
jge    1155 <main+0x35>
lea    0xeb9(%rip),%rdi
call   1040 <getgrnam@plt>
mov    %rax,-0x18(%rbp)
jmp    1166 <main+0x46>
mov    -0x10(%rbp),%rax
mov    0x8(%rax),%rdi
call   1040 <getgrnam@plt>
mov    %rax,-0x18(%rbp)
cmpq   $0x0,-0x18(%rbp)
jne    118b <main+0x6b>
lea    0xe8d(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
movl   $0xffffffff,-0x4(%rbp)
jmp    11b6 <main+0x96>
mov    -0x18(%rbp),%rax
mov    (%rax),%rsi
mov    -0x18(%rbp),%rax
mov    0x8(%rax),%rdx
mov    -0x18(%rbp),%rax
mov    0x10(%rax),%ecx
lea    0xe68(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
movl   $0x0,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbx
cmp    $0x2,%edi
jge    113f <main+0xf>
lea    0xec3(%rip),%rdi
jmp    1143 <main+0x13>
mov    0x8(%rsi),%rdi
call   1050 <getgrnam@plt>
test   %rax,%rax
je     1169 <main+0x39>
mov    (%rax),%rsi
mov    0x8(%rax),%rdx
mov    0x10(%rax),%ecx
lea    0xea7(%rip),%rdi
xor    %ebx,%ebx
xor    %eax,%eax
call   1040 <printf@plt>
jmp    117a <main+0x4a>
lea    0xec1(%rip),%rdi
call   1030 <puts@plt>
mov    $0xffffffff,%ebx
mov    %ebx,%eax
pop    %rbx
ret

LLVM IR (-O0):
%struct.group = type { i8*, i8*, i32 }
@.str = [5 x i8] c"root\00"
@.str.1 = [11 x i8] c"Not found\0A\00"
@.str.2 = [44 x i8] c"group name=%s,group_passwd=%s,group_gid=%d\0A\00"
define i32 @main(i32 %0, i8** %1) {
%3 = alloca i32
%4 = alloca i32
%5 = alloca i8**
%6 = alloca %struct.group*
%7 = alloca i32
store i32 0, i32* %3
store i32 %0, i32* %4
store i8** %1, i8*** %5
%8 = load i32, i32* %4
%9 = icmp slt i32 %8, 2
br i1 %9, label %10, label %12
10: ; preds = %2
%11 = call %struct.group* @getgrnam(i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str, i64 0, i64 0))
store %struct.group* %11, %struct.group** %6
br label %17
12: ; preds = %2
%13 = load i8**, i8*** %5
%14 = getelementptr inbounds i8*, i8** %13, i64 1
%15 = load i8*, i8** %14
%16 = call %struct.group* @getgrnam(i8* %15)
store %struct.group* %16, %struct.group** %6
br label %17
17: ; preds = %12, %10
%18 = load %struct.group*, %struct.group** %6
%19 = icmp eq %struct.group* %18, null
br i1 %19, label %20, label %22
20: ; preds = %17
%21 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([11 x i8], [11 x i8]* @.str.1, i64 0, i64 0))
store i32 -1, i32* %3
br label %33
22: ; preds = %17
%23 = load %struct.group*, %struct.group** %6
%24 = getelementptr inbounds %struct.group, %struct.group* %23, i32 0, i32 0
%25 = load i8*, i8** %24
%26 = load %struct.group*, %struct.group** %6
%27 = getelementptr inbounds %struct.group, %struct.group* %26, i32 0, i32 1
%28 = load i8*, i8** %27
%29 = load %struct.group*, %struct.group** %6
%30 = getelementptr inbounds %struct.group, %struct.group* %29, i32 0, i32 2
%31 = load i32, i32* %30
%32 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([44 x i8], [44 x i8]* @.str.2, i64 0, i64 0), i8* %25, i8* %28, i32 %31)
store i32 0, i32* %3
br label %33
33: ; preds = %22, %20
%34 = load i32, i32* %3
ret i32 %34
}

LLVM IR (-O2):
%struct.group = type { i8*, i8*, i32 }
@.str = [5 x i8] c"root\00"
@.str.2 = [44 x i8] c"group name=%s,group_passwd=%s,group_gid=%d\0A\00"
@str = [10 x i8] c"Not found\00"
define i32 @main(i32 %0, i8** nocapture %1) {
%3 = icmp slt i32 %0, 2
br i1 %3, label %7, label %4
4: ; preds = %2
%5 = getelementptr inbounds i8*, i8** %1, i64 1
%6 = load i8*, i8** %5
br label %7
7: ; preds = %2, %4
%8 = phi i8* [ %6, %4 ], [ getelementptr inbounds ([5 x i8], [5 x i8]* @.str, i64 0, i64 0), %2 ]
%9 = tail call %struct.group* @getgrnam(i8* %8)
%10 = icmp eq %struct.group* %9, null
br i1 %10, label %11, label %13
11: ; preds = %7
%12 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([10 x i8], [10 x i8]* @str, i64 0, i64 0))
br label %21
13: ; preds = %7
%14 = getelementptr inbounds %struct.group, %struct.group* %9, i64 0, i32 0
%15 = load i8*, i8** %14
%16 = getelementptr inbounds %struct.group, %struct.group* %9, i64 0, i32 1
%17 = load i8*, i8** %16
%18 = getelementptr inbounds %struct.group, %struct.group* %9, i64 0, i32 2
%19 = load i32, i32* %18
%20 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([44 x i8], [44 x i8]* @.str.2, i64 0, i64 0), i8* %15, i8* %17, i32 %19)
br label %21
21: ; preds = %13, %11
%22 = phi i32 [ -1, %11 ], [ 0, %13 ]
ret i32 %22
}