#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 /*<<< orphan*/ fgets(char *, int, int /*<<< orphan*/ *);
int /*<<< orphan*/ *popen(char *, char *);
int /*<<< orphan*/ printf(char *, char *);
int /*<<< orphan*/ putenv(char *);
int main(int argc, char *argv[]) {
  FILE *stream;
  char line[256];
  putenv("MAIN_DIALOG=<vbox>"
         "<text><label>G T K D I A L O G    C - L A N G   E X A M P L "
         "E</label></text>"
         "<frame Command buttons (defaults)>"
         "<hbox>"
         "<button ok></button>"
         "<button cancel></button>"
         "</hbox>"
         "<hbox>"
         "<text><label>this is a Label - static text in one string (nothing "
         "more)</label></text>"
         "<button help></button>"
         "</hbox>"
         "</frame>"
         "<frame Single-line & Multi-line string boxes>"
         "<entry>"
         "<default>Entry for single string input</default>"
         "<input>date</input>"
         "<variable>ENTRY</variable>"
         "</entry>"
         "<edit>"
         "<input file>inputfile</input>"
         "<variable>EDITOR</variable>"
         "</edit>"
         "</frame>"
         "<frame Label from command & system commands>"
         "<hbox>"
         "<text>"
         "<label>Static text (label) for Date</label>"
         "<input>date</input>"
         "<variable>DATE</variable>"
         "</text>"
         "<button>"
         "<label>Refresh Date-Time in Entry</label>"
         "<action>refresh:ENTRY</action>"
         "<label>date</label>"
         "</button>"
         "</hbox>"
         "<hbox>"
         "<button>"
         "<label>View kernel</label>"
         "<action>dmesg | zenity --text-info  --width=600 --height=500 --title "
         "View_kernel_messages</action>"
         "</button>"
         "<button>"
         "<label>Ethernet</label>"
         "<action>ifconfig | zenity --text-info  --width=480 --height=400 "
         "--title Ethernet</action>"
         "</button>"
         "<button>"
         "<label>PCI devices</label>"
         "<action>lspci | zenity --text-info  --width=720 --height=400 --title "
         "PCI_devices</action>"
         "</button>"
         "<button>"
         "<label>Loaded modules</label>"
         "<action>lsmod | zenity --text-info  --width=600 --height=400 --title "
         "Loaded_modules</action>"
         "</button>"
         "<button>"
         "<label>$PATH</label>"
         "<action>echo $PATH | zenity --text-info  --width=600 --height=25 "
         "--title user_PATH</action>"
         "</button>"
         "</hbox>"
         "</frame>"
         "<chooser>"
         "<height>250</height>"
         "<width>450</width>"
         "<variable>FILE</variable>"
         "<default>/home/</default>"
         "<action>cat [ echo $FILE ] | zenity --text-info  --width=720 "
         "--height=400 --title $FILE</action>"
         "</chooser>"
         "</vbox>");
  stream = popen("gtkdialog --program=MAIN_DIALOG", "r");
  fgets(line, 255, stream);
  printf("Last window-widget is: %s\n", line);
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x120,%rsp
movl   $0x0,-0x4(%rbp)
mov    %edi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
lea    0xea0(%rip),%rdi
call   1050 <putenv@plt>
lea    0x1540(%rip),%rdi
lea    0x1559(%rip),%rsi
call   1060 <popen@plt>
mov    %rax,-0x18(%rbp)
lea    -0x120(%rbp),%rdi
mov    -0x18(%rbp),%rdx
mov    $0xff,%esi
call   1040 <fgets@plt>
lea    -0x120(%rbp),%rsi
lea    0x152f(%rip),%rdi
call   1030 <printf@plt>
xor    %eax,%eax
add    $0x120,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbx
sub    $0x100,%rsp
lea    0xeb1(%rip),%rdi
call   1050 <putenv@plt>
lea    0x1551(%rip),%rdi
lea    0x156a(%rip),%rsi
call   1060 <popen@plt>
mov    %rsp,%rbx
mov    %rbx,%rdi
mov    $0xff,%esi
mov    %rax,%rdx
call   1040 <fgets@plt>
lea    0x154d(%rip),%rdi
mov    %rbx,%rsi
call   1030 <printf@plt>
xor    %eax,%eax
add    $0x100,%rsp
pop    %rbx
ret

LLVM IR (-O0):
@.str = [1708 x i8] c"MAIN_DIALOG=<vbox><text><label>G T K D I A L O G C - L A N G E X A M P L E</label></text><frame Command buttons (defaults)><hbox><button ok></button><button cancel></button></hbox><hbox><text><label>this is a Label - static text in one string (nothing more)</label></text><button help></button></hbox></frame><frame Single-line & Multi-line string boxes><entry><default>Entry for single string input</default><input>date</input><variable>ENTRY</variable></entry><edit><input file>inputfile</input><variable>EDITOR</variable></edit></frame><frame Label from command & system commands><hbox><text><label>Static text (label) for Date</label><input>date</input><variable>DATE</variable></text><button><label>Refresh Date-Time in Entry</label><action>refresh:ENTRY</action><label>date</label></button></hbox><hbox><button><label>View kernel</label><action>dmesg | zenity --text-info --width=600 --height=500 --title View_kernel_messages</action></button><button><label>Ethernet</label><action>ifconfig | zenity --text-info --width=480 --height=400 --title Ethernet</action></button><button><label>PCI devices</label><action>lspci | zenity --text-info --width=720 --height=400 --title PCI_devices</action></button><button><label>Loaded modules</label><action>lsmod | zenity --text-info --width=600 --height=400 --title Loaded_modules</action></button><button><label>$PATH</label><action>echo $PATH | zenity --text-info --width=600 --height=25 --title user_PATH</action></button></hbox></frame><chooser><height>250</height><width>450</width><variable>FILE</variable><default>/home/</default><action>cat [ echo $FILE ] | zenity --text-info --width=720 --height=400 --title $FILE</action></chooser></vbox>\00"
@.str.1 = [32 x i8] c"gtkdialog --program=MAIN_DIALOG\00"
@.str.2 = [2 x i8] c"r\00"
@.str.3 = [27 x i8] c"Last window-widget is: %s\0A\00"
define i32 @main(i32 %0, i8** %1) {
%3 = alloca i32
%4 = alloca i32
%5 = alloca i8**
%6 = alloca i32*
%7 = alloca [256 x i8]
store i32 0, i32* %3
store i32 %0, i32* %4
store i8** %1, i8*** %5
%8 = call i32 @putenv(i8* getelementptr inbounds ([1708 x i8], [1708 x i8]* @.str, i64 0, i64 0))
%9 = call i32* @popen(i8* getelementptr inbounds ([32 x i8], [32 x i8]* @.str.1, i64 0, i64 0), i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.2, i64 0, i64 0))
store i32* %9, i32** %6
%10 = getelementptr inbounds [256 x i8], [256 x i8]* %7, i64 0, i64 0
%11 = load i32*, i32** %6
%12 = call i32 @fgets(i8* %10, i32 255, i32* %11)
%13 = getelementptr inbounds [256 x i8], [256 x i8]* %7, i64 0, i64 0
%14 = call i32 @printf(i8* getelementptr inbounds ([27 x i8], [27 x i8]* @.str.3, i64 0, i64 0), i8* %13)
ret i32 0
}

LLVM IR (-O2):
@.str = [1708 x i8] c"MAIN_DIALOG=<vbox><text><label>G T K D I A L O G C - L A N G E X A M P L E</label></text><frame Command buttons (defaults)><hbox><button ok></button><button cancel></button></hbox><hbox><text><label>this is a Label - static text in one string (nothing more)</label></text><button help></button></hbox></frame><frame Single-line & Multi-line string boxes><entry><default>Entry for single string input</default><input>date</input><variable>ENTRY</variable></entry><edit><input file>inputfile</input><variable>EDITOR</variable></edit></frame><frame Label from command & system commands><hbox><text><label>Static text (label) for Date</label><input>date</input><variable>DATE</variable></text><button><label>Refresh Date-Time in Entry</label><action>refresh:ENTRY</action><label>date</label></button></hbox><hbox><button><label>View kernel</label><action>dmesg | zenity --text-info --width=600 --height=500 --title View_kernel_messages</action></button><button><label>Ethernet</label><action>ifconfig | zenity --text-info --width=480 --height=400 --title Ethernet</action></button><button><label>PCI devices</label><action>lspci | zenity --text-info --width=720 --height=400 --title PCI_devices</action></button><button><label>Loaded modules</label><action>lsmod | zenity --text-info --width=600 --height=400 --title Loaded_modules</action></button><button><label>$PATH</label><action>echo $PATH | zenity --text-info --width=600 --height=25 --title user_PATH</action></button></hbox></frame><chooser><height>250</height><width>450</width><variable>FILE</variable><default>/home/</default><action>cat [ echo $FILE ] | zenity --text-info --width=720 --height=400 --title $FILE</action></chooser></vbox>\00"
@.str.1 = [32 x i8] c"gtkdialog --program=MAIN_DIALOG\00"
@.str.2 = [2 x i8] c"r\00"
@.str.3 = [27 x i8] c"Last window-widget is: %s\0A\00"
define i32 @main(i32 %0, i8** nocapture readnone %1) {
%3 = alloca [256 x i8]
%4 = getelementptr inbounds [256 x i8], [256 x i8]* %3, i64 0, i64 0
%5 = tail call i32 @putenv(i8* getelementptr inbounds ([1708 x i8], [1708 x i8]* @.str, i64 0, i64 0))
%6 = tail call i32* @popen(i8* getelementptr inbounds ([32 x i8], [32 x i8]* @.str.1, i64 0, i64 0), i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.2, i64 0, i64 0))
%7 = call i32 @fgets(i8* %4, i32 255, i32* %6)
%8 = call i32 @printf(i8* getelementptr inbounds ([27 x i8], [27 x i8]* @.str.3, i64 0, i64 0), i8* %4)
ret i32 0
}